svnno****@sourc*****
svnno****@sourc*****
2009年 9月 21日 (月) 02:27:46 JST
Revision: 3644 http://sourceforge.jp/projects/jiemamy/svn/view?view=rev&revision=3644 Author: yamkazu Date: 2009-09-21 02:27:46 +0900 (Mon, 21 Sep 2009) Log Message: ----------- [GEN-96] 既存のコミット済みファイルに適切なsvnプロパティを設定 Modified Paths: -------------- leto/factory-enhancer/trunk/LICENSE.txt leto/factory-enhancer/trunk/license/LICENSE.hamcrest.txt leto/factory-enhancer/trunk/license/LICENSE.logback.txt leto/factory-enhancer/trunk/license/LICENSE.slf4j.txt leto/factory-enhancer/trunk/license/list.txt leto/generic-tree/trunk/LICENSE.txt leto/generic-tree/trunk/license/LICENSE.hamcrest.txt leto/generic-tree/trunk/license/LICENSE.logback.txt leto/generic-tree/trunk/license/LICENSE.slf4j.txt leto/generic-tree/trunk/license/list.txt leto/generic-tree/trunk/pom.xml leto/jiemamy-commons/trunk/LICENSE.txt leto/jiemamy-commons/trunk/license/LICENSE.hamcrest.txt leto/jiemamy-commons/trunk/license/LICENSE.logback.txt leto/jiemamy-commons/trunk/license/LICENSE.slf4j.txt leto/jiemamy-commons/trunk/license/list.txt leto/jiemamy-commons/trunk/pom.xml leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/exception/JiemamyError.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/AnnotationUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ArrayEssentialStack.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ArrayMap.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassLoaderUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassPoolUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassTraversal.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/CollectionsUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ConstructorUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/DateUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/Disposable.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/DisposableUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EnumerationIterator.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialQueue.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialStack.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialStacks.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FieldUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileInputStreamUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileOutputStreamUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ForEachUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/GenericUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/InputStreamUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/IterableNodeList.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarFileUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarInputStreamUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarURLConnectionUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JmIOUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JmStringUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/LinkedEssentialQueue.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ListUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/LogMarker.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/MethodUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ModifierUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/OutputStreamUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/PropertyNotFoundException.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ReflectionUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceBundleUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceNotFoundException.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceTraversal.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourcesUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResultSetUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/SqlExecuter.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/SqlExecutor.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/StringUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/TraversalHandlerException.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/URLUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/UUIDUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ValidateUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ZipFileUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/AttributesMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/BestRowIdentifierMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/CatalogMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ColumnMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ColumnPrivilegeMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/IndexInfoMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/KeyMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/PrimaryKeyMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ProcedureColumnsMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ProcedureMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SchemaMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SuperTableMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SuperTypeMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TableMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TablePrivilegeMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TableTypeMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TypeInfoMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TypeSafeDatabaseMetaData.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/UDTMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/VersionColumnMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/package-info.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/JmStringUtilTest.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ListUtilTest.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/SqlExecutorTest.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/UUIDUtilTest.java leto/jiemamy-commons/trunk/src/test/resources/logback.xml leto/jiemamy-entity-io/trunk/LICENSE.txt leto/jiemamy-entity-io/trunk/license/LICENSE.hamcrest.txt leto/jiemamy-entity-io/trunk/license/LICENSE.logback.txt leto/jiemamy-entity-io/trunk/license/LICENSE.slf4j.txt leto/jiemamy-entity-io/trunk/license/list.txt leto/jiemamy-entity-io/trunk/pom.xml leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/ProductInfo.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/annotation/ColumnName.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/annotation/TableName.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/convensition/PersistenceConvention.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/convensition/impl/PersistenceConventionImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AssociationDesc.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AssociationType.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AttributeDesc.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AttributeDescFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/CompositeUniqueConstraintDesc.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/CompositeUniqueConstraintDescFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescSetWriterContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescSetWriterFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDesc.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriter.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriterContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriterFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntitySetDesc.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntitySetDescFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/AssociationResolver.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/AttributeDescFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/CompositeUniqueConstraintDescFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescSetWriterImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntitySetDescFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/IdentityNotSupportedException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/PluralFormDictinary.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/GenDialect.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/SqlType.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/StandardGenDialect.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/GenerateException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/Generator.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/GeneratorContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/DeleteEmptyFileWriter.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/GeneratorContextImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/GeneratorImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/IncludeDirective.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/OnDemandDateModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/ResourceTemplateLoader.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbColumnMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbForeignKeyMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbTableMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbTableMetaReader.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbUniqueKeyMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/impl/DbTableMetaReaderImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AssociationModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AssociationModelFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AttributeModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AttributeModelFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/ClassModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/CompositeUniqueConstraintModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/CompositeUniqueConstraintModelFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/EntityModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/EntityModelFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/GeneratedModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/JoinColumnModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/JoinColumnsModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/UniqueKeyModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/AssociationModelFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/AttributeModelFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/ClassModelSupport.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/CompositeUniqueConstraintModelFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/EntityModelFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/GeneratedModelSupport.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/CannotCreatePropertyException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnDuplicatedException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnMetaFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityMetaReaderContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityMetaReaderFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityClassNotFoundException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityColumnNotFoundException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaCommand.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReader.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReaderContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReaderFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/JoinColumnMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/NonEntityException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyDuplicatedException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyMetaFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/RelationshipType.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/TableMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/TableMetaFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/BothMappedByAndJoinColumnException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/FieldDuplicatedException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/IdGeneratorNotFoundException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/JoinColumnNameAndReferencedColumnNameMandatoryException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/LazyFetchSpecifiedException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/MappedByMandatoryException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/OneToManyNotGenericsException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/OneToManyNotListException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/RelationshipNotEntityException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/TemporalTypeNotSpecifiedException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedInheritanceException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedPropertyTypesException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedRelationshipException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/VersionPropertyNotNumberException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/AbstractIdGeneratorMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/AbstractPreAllocateIdGeneratorMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/IdGeneratorMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/IdentityIdGeneratorMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/SequenceIdGeneratorMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/TableIdGeneratorMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/ColumnMetaFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityLogicalNameReadCommand.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityMetaFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityMetaReaderImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/PropertyMetaFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/TableMetaFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/AnnotationUtil.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/CaseInsensitiveMap.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/CaseInsensitiveSet.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ColumnUtil.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/FileUtil.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ReferentialActionType.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ReferentialConstraint.java leto/jiemamy-entity-io/trunk/src/test/java/example/entity/Depertment.java leto/jiemamy-entity-io/trunk/src/test/java/example/entity/Employee.java leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescSetWriterImplTest.java leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/EntityMetaReaderImplTest.java leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/TestDialect.java leto/jiemamy-entity-io/trunk/src/test/resources/META-INF/maven/org.jiemamy/jiemamy-entity-io/pom.properties leto/jiemamy-entity-io/trunk/src/test/resources/logback.xml zeus/trunk/jiemamy-test-helper/LICENSE.txt zeus/trunk/jiemamy-test-helper/license/LICENSE.hamcrest.txt zeus/trunk/jiemamy-test-helper/license/LICENSE.logback.txt zeus/trunk/jiemamy-test-helper/license/LICENSE.slf4j.txt zeus/trunk/jiemamy-test-helper/license/list.txt zeus/trunk/jiemamy-test-helper/pom.xml zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/AbstractTestModelBuilder.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/Instruction.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/JiemamyAssert.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/ModelUtil.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelsTestBase.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/UuidStrategy.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockBuiltinDataType.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockBuiltinDataTypeMold.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDataTypeResolver.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDialect.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDialectProvider.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockScriptEngine.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockServiceLocator.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockValidator.java zeus/trunk/jiemamy-test-helper/src/test/java/org/jiemamy/internal/test/JiemamyAssertTest.java zeus/trunk/jiemamy-test-helper/src/test/resources/logback.xml Property Changed: ---------------- leto/factory-enhancer/trunk/LICENSE.txt leto/factory-enhancer/trunk/license/LICENSE.hamcrest.txt leto/factory-enhancer/trunk/license/LICENSE.javassist.html leto/factory-enhancer/trunk/license/LICENSE.junit.html leto/factory-enhancer/trunk/license/LICENSE.logback.txt leto/factory-enhancer/trunk/license/LICENSE.slf4j.txt leto/factory-enhancer/trunk/license/list.txt leto/factory-enhancer/trunk/pom.xml leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/Enhance.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/EnhanceException.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/FactoryEnhancer.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/Invocation.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/InvocationHandler.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/InvocationPointcut.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/Pointcuts.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/AccessibilityValidator.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/AdviceApplier.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/AdviceTable.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/AndInvocationPointcut.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/Aspect.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/AspectList.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/ConstructorInvocation.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/CtClassComparator.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/DelegateInvocation.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/EmptyClassLoader.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/EnhanceManager.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/EnhanceManipulator.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/EnhanceTargetProductCollector.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/JavassistConverter.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/MethodInvocation.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/NewInstanceEnhancer.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/NotInvocationPointcut.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/OrInvocationPointcut.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/package-info.java leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/package-info.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessPackageConstructor.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessPackageField.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessPackageMethod.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessProtectedConstructor.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessProtectedField.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessProtectedMethod.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessSelfInvisibles.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/ArrayFactory.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/ArrayFactoryImpl.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactory.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryAbstract.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryClass.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryEnum.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryExtended.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryFinal.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryInterface.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryPackagePrivate.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/FactoryEnhancerTest.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/HasBridge.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/HasBridgeFactory.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/IndependentFactoryImpl.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/PluralFactoryImpl.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/PointcutsTest.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/SingularFactory.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/SingularFactoryNoPublicProduct.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetComponent.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetComponentOnlyType.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetFactory.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetFactoryImpl.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetProduct1.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetProduct2.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetProduct3.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetProductBase.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetProductFinal.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/AddPointcut.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/AfterIntIncrementHandler.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/AfterStringAppendHandler.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/ArrayParameterPointcut.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/BeforeStringInsertHandler.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/ClassSuffixPointcut.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/IntResultPointcut.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/StringParameterPointcut.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/StringResultPointcut.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/SuffixPointcut.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/ThroughHandler.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/ThrowExceptionHandler.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/ToStringPointcut.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/AdviceApplierTest.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/ConstructorInvocationTest.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/ConstructorTestTarget.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/DelegateInvocationTest.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/ExtConstructorTestTarget.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/JavassistConverterTest.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/MethodInvocationTest.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/MethodTestTarget.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/MockInvocation.java leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/OrthogonalMethodTestTarget.java leto/factory-enhancer/trunk/src/test/resources/logback.xml leto/factory-enhancer-example/trunk/pom.xml leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_01hello/Factory.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_01hello/FactoryImpl.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_01hello/Greetings.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_01hello/HandleAndTrace.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_01hello/Main.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_01hello/SayPointcut.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/Calculator.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/Factory.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/FactoryImpl.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/FirstParamMult3.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/Main.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/MinusResult.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/NamePointcut.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/ReturnIntPointcut.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/TakeIntIntPointcut.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/AppendToList.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/ArrayListPointcut.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/DuplicateStringParam.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/Factory.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/FactoryImpl.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/ForceTitledList.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/Main.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/TitledList.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/TitledListPointcut.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_04observe/Factory.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_04observe/FactoryImpl.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_04observe/Main.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_04observe/Observer.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_04observe/SetterPointcut.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/Bar.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/ExtensionEnhancePointcut.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/ExtensionEnhancer.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/Factory.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/FactoryExtension.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/FactoryImpl.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/Foo.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/FooEnhancePointcut.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/FooEnhancer.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/FooExt.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/Hoge.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/HogeEnhancePointcut.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/HogeEnhancer.java leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/Main.java leto/factory-enhancer-example/trunk/src/main/resources/logback.xml leto/generic-tree/trunk/LICENSE.txt leto/generic-tree/trunk/license/LICENSE.hamcrest.txt leto/generic-tree/trunk/license/LICENSE.junit.html leto/generic-tree/trunk/license/LICENSE.logback.txt leto/generic-tree/trunk/license/LICENSE.slf4j.txt leto/generic-tree/trunk/license/list.txt leto/generic-tree/trunk/pom.xml leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/ArrayConverter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/CachedObjectConverter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/CharStringConverter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/CollectionConverter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/ConverterDriver.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/DefaultObjectConverter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/EnumConverter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/GeneralObjectConverter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/InterfaceBeanConverter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/MapConverter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/ObjectConverter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/PrimitiveConverter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/Element.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/ElementVisitor.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/Entry.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/Record.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/Sequence.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/Terminal.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/Value.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/rewrite/RewriteRule.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/rewrite/Rewriter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/rewrite/ValueRewriter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/text/Emitter.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/text/JavaEscape.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/text/Parser.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/text/Variables.java leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/text/package-info.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/ArrayConverterTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/CachedObjectConverterTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/CharStringConverterTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/CollectionConverterTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/EnumConverterTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/GeneralObjectConverterTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/InterfaceBeanConverterTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/MapConverterTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/MockObjectConverter.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/PrimitiveConverterTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/BadProperties.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/BadPropertiesImpl.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/Bean.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/EnhancedBean.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/IndirectVia.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/InheritedBean.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/Poji.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/Pojo.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/Via.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/ViaImpl.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/Attribute.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/ColmunImpl.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/Column.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/Main.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/Root.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/RootImpl.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/Table.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/TableImpl.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/Type.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/driver/AnnotatedObjectConverter.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/driver/Foo.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/driver/Hoge.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/driver/HogeImpl.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/driver/Main.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/driver/PrimaryInterface.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/rewrite/EmptyEliminator.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/rewrite/Main.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/model/EntryTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/model/RecordTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/model/SequenceTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/model/TerminalTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/rewrite/RewriterTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/rewrite/ValueRewriterTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/text/EmitterTest.java leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/text/ParserTest.java leto/jiemamy-commons/trunk/LICENSE.txt leto/jiemamy-commons/trunk/license/LICENSE.hamcrest.txt leto/jiemamy-commons/trunk/license/LICENSE.junit.html leto/jiemamy-commons/trunk/license/LICENSE.logback.txt leto/jiemamy-commons/trunk/license/LICENSE.slf4j.txt leto/jiemamy-commons/trunk/license/list.txt leto/jiemamy-commons/trunk/pom.xml leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/exception/JiemamyError.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/AnnotationUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ArrayEssentialStack.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ArrayMap.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassLoaderUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassPoolUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassTraversal.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/CollectionsUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ConstructorUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/DateUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/Disposable.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/DisposableUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EnumerationIterator.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialQueue.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialStack.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialStacks.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FieldUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileInputStreamUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileOutputStreamUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ForEachUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/GenericUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/InputStreamUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/IterableNodeList.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarFileUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarInputStreamUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarURLConnectionUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JmIOUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JmStringUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/LinkedEssentialQueue.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ListUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/LogMarker.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/MethodUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ModifierUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/OutputStreamUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/PropertyNotFoundException.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ReflectionUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceBundleUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceNotFoundException.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceTraversal.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourcesUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResultSetUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/SqlExecuter.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/SqlExecutor.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/StringUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/TraversalHandlerException.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/URLUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/UUIDUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ValidateUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ZipFileUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/AttributesMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/BestRowIdentifierMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/CatalogMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ColumnMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ColumnPrivilegeMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/IndexInfoMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/KeyMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/PrimaryKeyMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ProcedureColumnsMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ProcedureMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SchemaMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SuperTableMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SuperTypeMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TableMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TablePrivilegeMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TableTypeMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TypeInfoMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TypeSafeDatabaseMetaData.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/UDTMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/VersionColumnMeta.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/package-info.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/JmStringUtilTest.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ListUtilTest.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/SqlExecutorTest.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/UUIDUtilTest.java leto/jiemamy-commons/trunk/src/test/resources/logback.xml leto/jiemamy-entity-io/trunk/LICENSE.txt leto/jiemamy-entity-io/trunk/license/LICENSE.hamcrest.txt leto/jiemamy-entity-io/trunk/license/LICENSE.junit.html leto/jiemamy-entity-io/trunk/license/LICENSE.logback.txt leto/jiemamy-entity-io/trunk/license/LICENSE.slf4j.txt leto/jiemamy-entity-io/trunk/license/list.txt leto/jiemamy-entity-io/trunk/pom.xml leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/ProductInfo.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/annotation/ColumnName.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/annotation/TableName.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/convensition/PersistenceConvention.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/convensition/impl/PersistenceConventionImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AssociationDesc.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AssociationType.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AttributeDesc.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AttributeDescFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/CompositeUniqueConstraintDesc.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/CompositeUniqueConstraintDescFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescSetWriterContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescSetWriterFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDesc.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriter.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriterContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriterFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntitySetDesc.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntitySetDescFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/AssociationResolver.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/AttributeDescFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/CompositeUniqueConstraintDescFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescSetWriterImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntitySetDescFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/IdentityNotSupportedException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/PluralFormDictinary.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/GenDialect.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/SqlType.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/StandardGenDialect.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/GenerateException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/Generator.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/GeneratorContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/DeleteEmptyFileWriter.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/GeneratorContextImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/GeneratorImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/IncludeDirective.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/OnDemandDateModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/ResourceTemplateLoader.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbColumnMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbForeignKeyMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbTableMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbTableMetaReader.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbUniqueKeyMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/impl/DbTableMetaReaderImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AssociationModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AssociationModelFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AttributeModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AttributeModelFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/ClassModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/CompositeUniqueConstraintModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/CompositeUniqueConstraintModelFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/EntityModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/EntityModelFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/GeneratedModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/JoinColumnModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/JoinColumnsModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/UniqueKeyModel.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/AssociationModelFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/AttributeModelFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/ClassModelSupport.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/CompositeUniqueConstraintModelFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/EntityModelFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/GeneratedModelSupport.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/CannotCreatePropertyException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnDuplicatedException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnMetaFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityMetaReaderContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityMetaReaderFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityClassNotFoundException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityColumnNotFoundException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaCommand.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReader.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReaderContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReaderFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/JoinColumnMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/NonEntityException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyDuplicatedException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyMetaFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/RelationshipType.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/TableMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/TableMetaFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/BothMappedByAndJoinColumnException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/FieldDuplicatedException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/IdGeneratorNotFoundException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/JoinColumnNameAndReferencedColumnNameMandatoryException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/LazyFetchSpecifiedException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/MappedByMandatoryException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/OneToManyNotGenericsException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/OneToManyNotListException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/RelationshipNotEntityException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/TemporalTypeNotSpecifiedException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedInheritanceException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedPropertyTypesException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedRelationshipException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/VersionPropertyNotNumberException.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/AbstractIdGeneratorMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/AbstractPreAllocateIdGeneratorMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/IdGeneratorMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/IdentityIdGeneratorMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/SequenceIdGeneratorMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/TableIdGeneratorMeta.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/ColumnMetaFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityLogicalNameReadCommand.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityMetaFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityMetaReaderImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/PropertyMetaFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/TableMetaFactoryImpl.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/AnnotationUtil.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/CaseInsensitiveMap.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/CaseInsensitiveSet.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ColumnUtil.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/FileUtil.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ReferentialActionType.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ReferentialConstraint.java leto/jiemamy-entity-io/trunk/src/test/java/example/entity/Depertment.java leto/jiemamy-entity-io/trunk/src/test/java/example/entity/Employee.java leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescSetWriterImplTest.java leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/EntityMetaReaderImplTest.java leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/TestDialect.java leto/jiemamy-entity-io/trunk/src/test/resources/META-INF/maven/org.jiemamy/jiemamy-entity-io/pom.properties leto/jiemamy-entity-io/trunk/src/test/resources/logback.xml zeus/trunk/jiemamy-test-helper/LICENSE.txt zeus/trunk/jiemamy-test-helper/license/LICENSE.hamcrest.txt zeus/trunk/jiemamy-test-helper/license/LICENSE.junit.html zeus/trunk/jiemamy-test-helper/license/LICENSE.logback.txt zeus/trunk/jiemamy-test-helper/license/LICENSE.slf4j.txt zeus/trunk/jiemamy-test-helper/license/list.txt zeus/trunk/jiemamy-test-helper/pom.xml zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/AbstractTestModelBuilder.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/Instruction.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/JiemamyAssert.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/ModelUtil.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelsTestBase.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/UuidStrategy.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockBuiltinDataType.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockBuiltinDataTypeMold.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDataTypeResolver.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDialect.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDialectProvider.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockScriptEngine.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockServiceLocator.java zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockValidator.java zeus/trunk/jiemamy-test-helper/src/test/java/org/jiemamy/internal/test/JiemamyAssertTest.java zeus/trunk/jiemamy-test-helper/src/test/resources/logback.xml Modified: leto/factory-enhancer/trunk/LICENSE.txt =================================================================== --- leto/factory-enhancer/trunk/LICENSE.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/factory-enhancer/trunk/LICENSE.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. Property changes on: leto/factory-enhancer/trunk/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/factory-enhancer/trunk/license/LICENSE.hamcrest.txt =================================================================== --- leto/factory-enhancer/trunk/license/LICENSE.hamcrest.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/factory-enhancer/trunk/license/LICENSE.hamcrest.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,27 +1,27 @@ -BSD License - -Copyright (c) 2000-2006, www.hamcrest.org -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of -conditions and the following disclaimer. Redistributions in binary form must reproduce -the above copyright notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -Neither the name of Hamcrest nor the names of its contributors may be used to endorse -or promote products derived from this software without specific prior written -permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT -SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY -WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. +BSD License + +Copyright (c) 2000-2006, www.hamcrest.org +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. Redistributions in binary form must reproduce +the above copyright notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the distribution. + +Neither the name of Hamcrest nor the names of its contributors may be used to endorse +or promote products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. Property changes on: leto/factory-enhancer/trunk/license/LICENSE.hamcrest.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/factory-enhancer/trunk/license/LICENSE.javassist.html ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/html Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/factory-enhancer/trunk/license/LICENSE.junit.html ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/html Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/factory-enhancer/trunk/license/LICENSE.logback.txt =================================================================== --- leto/factory-enhancer/trunk/license/LICENSE.logback.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/factory-enhancer/trunk/license/LICENSE.logback.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,22 +1,22 @@ -Logback LICENSE ---------------- - -Logback: the reliable, generic, fast and flexible logging library for -Java. - -Copyright (C) 2000-2008, QOS.ch - -Source code and binaries for logback, including logback-core, -logback-classic and logback-access modules, are distributed under the -GNU Lesser General Public License Version 2.1, as published by the -Free Software Foundation. - -This library 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 2.1 of the -License, or (at your option) any later version. - -This library 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. +Logback LICENSE +--------------- + +Logback: the reliable, generic, fast and flexible logging library for +Java. + +Copyright (C) 2000-2008, QOS.ch + +Source code and binaries for logback, including logback-core, +logback-classic and logback-access modules, are distributed under the +GNU Lesser General Public License Version 2.1, as published by the +Free Software Foundation. + +This library 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 2.1 of the +License, or (at your option) any later version. + +This library 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. Property changes on: leto/factory-enhancer/trunk/license/LICENSE.logback.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/factory-enhancer/trunk/license/LICENSE.slf4j.txt =================================================================== --- leto/factory-enhancer/trunk/license/LICENSE.slf4j.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/factory-enhancer/trunk/license/LICENSE.slf4j.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,24 +1,24 @@ -Copyright (c) 2004-2008 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - +Copyright (c) 2004-2008 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + Property changes on: leto/factory-enhancer/trunk/license/LICENSE.slf4j.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/factory-enhancer/trunk/license/list.txt =================================================================== --- leto/factory-enhancer/trunk/license/list.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/factory-enhancer/trunk/license/list.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,20 +1,20 @@ -MIT License: - SLF4J API Module, - JCL 1.1.1 implemented over SLF4J - -MPL or LGPL dual license: - Javassist - -BSD style: - Hamcrest Core, - Hamcrest Library, - -Common Public License Version 1.0: - JUnit - -GNU Lesser General Public License: - Logback Classic Module, - Logback Core Module - -The Apache Software License, Version 2.0: - Factory Enhancer +MIT License: + SLF4J API Module, + JCL 1.1.1 implemented over SLF4J + +MPL or LGPL dual license: + Javassist + +BSD style: + Hamcrest Core, + Hamcrest Library, + +Common Public License Version 1.0: + JUnit + +GNU Lesser General Public License: + Logback Classic Module, + Logback Core Module + +The Apache Software License, Version 2.0: + Factory Enhancer Property changes on: leto/factory-enhancer/trunk/license/list.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/factory-enhancer/trunk/pom.xml ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/Enhance.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/EnhanceException.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/FactoryEnhancer.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/Invocation.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/InvocationHandler.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/InvocationPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/Pointcuts.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/AccessibilityValidator.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/AdviceApplier.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/AdviceTable.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/AndInvocationPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/Aspect.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/AspectList.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/ConstructorInvocation.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/CtClassComparator.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/DelegateInvocation.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/EmptyClassLoader.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/EnhanceManager.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/EnhanceManipulator.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/EnhanceTargetProductCollector.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/JavassistConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/MethodInvocation.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/NewInstanceEnhancer.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/NotInvocationPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/OrInvocationPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/helper/package-info.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/main/java/org/jiemamy/utils/enhancer/package-info.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessPackageConstructor.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessPackageField.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessPackageMethod.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessProtectedConstructor.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessProtectedField.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessProtectedMethod.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/AccessSelfInvisibles.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/ArrayFactory.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/ArrayFactoryImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactory.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryAbstract.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryClass.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryEnum.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryExtended.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryFinal.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryInterface.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/EmptyFactoryPackagePrivate.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/FactoryEnhancerTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/HasBridge.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/HasBridgeFactory.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/IndependentFactoryImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/PluralFactoryImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/PointcutsTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/SingularFactory.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/SingularFactoryNoPublicProduct.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetComponent.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetComponentOnlyType.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetFactory.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetFactoryImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetProduct1.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetProduct2.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetProduct3.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetProductBase.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/TargetProductFinal.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/AddPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/AfterIntIncrementHandler.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/AfterStringAppendHandler.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/ArrayParameterPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/BeforeStringInsertHandler.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/ClassSuffixPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/IntResultPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/StringParameterPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/StringResultPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/SuffixPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/ThroughHandler.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/ThrowExceptionHandler.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/aspect/ToStringPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/AdviceApplierTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/ConstructorInvocationTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/ConstructorTestTarget.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/DelegateInvocationTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/ExtConstructorTestTarget.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/JavassistConverterTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/MethodInvocationTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/MethodTestTarget.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/MockInvocation.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/java/org/jiemamy/utils/enhancer/helper/OrthogonalMethodTestTarget.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer/trunk/src/test/resources/logback.xml ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/pom.xml ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_01hello/Factory.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_01hello/FactoryImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_01hello/Greetings.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_01hello/HandleAndTrace.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_01hello/Main.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_01hello/SayPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/Calculator.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/Factory.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/FactoryImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/FirstParamMult3.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/Main.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/MinusResult.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/NamePointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/ReturnIntPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_02hookmethod/TakeIntIntPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/AppendToList.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/ArrayListPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/DuplicateStringParam.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/Factory.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/FactoryImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/ForceTitledList.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/Main.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/TitledList.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_03hooknew/TitledListPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_04observe/Factory.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_04observe/FactoryImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_04observe/Main.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_04observe/Observer.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_04observe/SetterPointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/Bar.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/ExtensionEnhancePointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/ExtensionEnhancer.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/Factory.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/FactoryExtension.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/FactoryImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/Foo.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/FooEnhancePointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/FooEnhancer.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/FooExt.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/Hoge.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/HogeEnhancePointcut.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/HogeEnhancer.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/java/org/jiemamy/util/enhancer/example/_05extension/Main.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/factory-enhancer-example/trunk/src/main/resources/logback.xml ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Modified: leto/generic-tree/trunk/LICENSE.txt =================================================================== --- leto/generic-tree/trunk/LICENSE.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/generic-tree/trunk/LICENSE.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. Property changes on: leto/generic-tree/trunk/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/generic-tree/trunk/license/LICENSE.hamcrest.txt =================================================================== --- leto/generic-tree/trunk/license/LICENSE.hamcrest.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/generic-tree/trunk/license/LICENSE.hamcrest.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,27 +1,27 @@ -BSD License - -Copyright (c) 2000-2006, www.hamcrest.org -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of -conditions and the following disclaimer. Redistributions in binary form must reproduce -the above copyright notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -Neither the name of Hamcrest nor the names of its contributors may be used to endorse -or promote products derived from this software without specific prior written -permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT -SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY -WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. +BSD License + +Copyright (c) 2000-2006, www.hamcrest.org +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. Redistributions in binary form must reproduce +the above copyright notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the distribution. + +Neither the name of Hamcrest nor the names of its contributors may be used to endorse +or promote products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. Property changes on: leto/generic-tree/trunk/license/LICENSE.hamcrest.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/generic-tree/trunk/license/LICENSE.junit.html ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/html Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/generic-tree/trunk/license/LICENSE.logback.txt =================================================================== --- leto/generic-tree/trunk/license/LICENSE.logback.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/generic-tree/trunk/license/LICENSE.logback.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,22 +1,22 @@ -Logback LICENSE ---------------- - -Logback: the reliable, generic, fast and flexible logging library for -Java. - -Copyright (C) 2000-2008, QOS.ch - -Source code and binaries for logback, including logback-core, -logback-classic and logback-access modules, are distributed under the -GNU Lesser General Public License Version 2.1, as published by the -Free Software Foundation. - -This library 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 2.1 of the -License, or (at your option) any later version. - -This library 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. +Logback LICENSE +--------------- + +Logback: the reliable, generic, fast and flexible logging library for +Java. + +Copyright (C) 2000-2008, QOS.ch + +Source code and binaries for logback, including logback-core, +logback-classic and logback-access modules, are distributed under the +GNU Lesser General Public License Version 2.1, as published by the +Free Software Foundation. + +This library 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 2.1 of the +License, or (at your option) any later version. + +This library 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. Property changes on: leto/generic-tree/trunk/license/LICENSE.logback.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/generic-tree/trunk/license/LICENSE.slf4j.txt =================================================================== --- leto/generic-tree/trunk/license/LICENSE.slf4j.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/generic-tree/trunk/license/LICENSE.slf4j.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,24 +1,24 @@ -Copyright (c) 2004-2008 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - +Copyright (c) 2004-2008 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + Property changes on: leto/generic-tree/trunk/license/LICENSE.slf4j.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/generic-tree/trunk/license/list.txt =================================================================== --- leto/generic-tree/trunk/license/list.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/generic-tree/trunk/license/list.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,18 +1,18 @@ -MIT License: - SLF4J API Module, - JCL 1.1.1 implemented over SLF4J - -BSD style: - Hamcrest Core, - Hamcrest Library - -Common Public License Version 1.0: - JUnit - -GNU Lesser General Public License: - Logback Classic Module, - Logback Core Module - -The Apache Software License, Version 2.0: - Generic Tree Utilities - +MIT License: + SLF4J API Module, + JCL 1.1.1 implemented over SLF4J + +BSD style: + Hamcrest Core, + Hamcrest Library + +Common Public License Version 1.0: + JUnit + +GNU Lesser General Public License: + Logback Classic Module, + Logback Core Module + +The Apache Software License, Version 2.0: + Generic Tree Utilities + Property changes on: leto/generic-tree/trunk/license/list.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/generic-tree/trunk/pom.xml =================================================================== --- leto/generic-tree/trunk/pom.xml 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/generic-tree/trunk/pom.xml 2009-09-20 17:27:46 UTC (rev 3644) @@ -2,29 +2,29 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> + <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.jiemamy</groupId> <artifactId>master</artifactId> <version>1.1</version> </parent> <groupId>org.jiemamy</groupId> - <artifactId>generic-tree</artifactId> - <name>Generic Tree Utilities</name> - <version>0.1.1-SNAPSHOT</version> + <artifactId>generic-tree</artifactId> + <name>Generic Tree Utilities</name> + <version>0.1.1-SNAPSHOT</version> <url>http://report.jiemamy.org/generic-tree</url> - <ciManagement> - <system>hudson</system> - <url>http://hudson.jiemamy.org/hudson/job/generic-tree/</url> - <notifiers> - <notifier> - <sendOnSuccess>false</sendOnSuccess> - <configuration> - <recipients>jiema****@googl*****</recipients> - </configuration> - </notifier> - </notifiers> - </ciManagement> + <ciManagement> + <system>hudson</system> + <url>http://hudson.jiemamy.org/hudson/job/generic-tree/</url> + <notifiers> + <notifier> + <sendOnSuccess>false</sendOnSuccess> + <configuration> + <recipients>jiema****@googl*****</recipients> + </configuration> + </notifier> + </notifiers> + </ciManagement> <inceptionYear>2009</inceptionYear> <developers> <developer> @@ -47,58 +47,58 @@ <url>http://maven.jiemamy.org/release</url> </repository> </repositories> - <pluginRepositories> - <pluginRepository> - <id>jflex</id> - <name>JFlex repository</name> - <url>http://jflex.sourceforge.net/repo/</url> - </pluginRepository> - </pluginRepositories> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>javacc-maven-plugin</artifactId> - <version>2.5</version> - <executions> - <execution> - <id>javacc</id> - <goals> - <goal>javacc</goal> - </goals> - <configuration> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>de.jflex.maven.plugin</groupId> - <artifactId>maven-jflex-plugin</artifactId> - <version>1.0</version> - <executions> - <execution> - <goals> - <goal>generate</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.5</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <version>1.1</version> - <scope>test</scope> - </dependency> + <pluginRepositories> + <pluginRepository> + <id>jflex</id> + <name>JFlex repository</name> + <url>http://jflex.sourceforge.net/repo/</url> + </pluginRepository> + </pluginRepositories> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>javacc-maven-plugin</artifactId> + <version>2.5</version> + <executions> + <execution> + <id>javacc</id> + <goals> + <goal>javacc</goal> + </goals> + <configuration> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>de.jflex.maven.plugin</groupId> + <artifactId>maven-jflex-plugin</artifactId> + <version>1.0</version> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + <dependencies> <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-library</artifactId> + <version>1.1</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.5.6</version> @@ -108,15 +108,15 @@ <artifactId>jcl-over-slf4j</artifactId> <version>1.5.6</version> </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-core</artifactId> - <version>0.9.15</version> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <version>0.9.15</version> - </dependency> - </dependencies> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>0.9.15</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>0.9.15</version> + </dependency> + </dependencies> </project> \ No newline at end of file Property changes on: leto/generic-tree/trunk/pom.xml ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/ArrayConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/CachedObjectConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/CharStringConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/CollectionConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/ConverterDriver.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/DefaultObjectConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/EnumConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/GeneralObjectConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/InterfaceBeanConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/MapConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/ObjectConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/converter/PrimitiveConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/Element.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/ElementVisitor.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/Entry.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/Record.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/Sequence.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/Terminal.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/model/Value.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/rewrite/RewriteRule.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/rewrite/Rewriter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/rewrite/ValueRewriter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/text/Emitter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/text/JavaEscape.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/text/Parser.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/text/Variables.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/main/java/org/jiemamy/utils/gtree/text/package-info.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/ArrayConverterTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/CachedObjectConverterTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/CharStringConverterTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/CollectionConverterTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/EnumConverterTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/GeneralObjectConverterTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/InterfaceBeanConverterTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/MapConverterTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/MockObjectConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/PrimitiveConverterTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/BadProperties.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/BadPropertiesImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/Bean.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/EnhancedBean.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/IndirectVia.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/InheritedBean.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/Poji.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/Pojo.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/Via.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/converter/bean/ViaImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/Attribute.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/ColmunImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/Column.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/Main.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/Root.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/RootImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/Table.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/TableImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/Type.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/driver/AnnotatedObjectConverter.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/driver/Foo.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/driver/Hoge.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/driver/HogeImpl.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/driver/Main.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/driver/PrimaryInterface.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/rewrite/EmptyEliminator.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/example/rewrite/Main.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/model/EntryTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/model/RecordTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/model/SequenceTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/model/TerminalTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/rewrite/RewriterTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/rewrite/ValueRewriterTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/text/EmitterTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Property changes on: leto/generic-tree/trunk/src/test/java/org/jiemamy/utils/gtree/text/ParserTest.java ___________________________________________________________________ Modified: svn:keywords - Date Author Id Revision HeadURL + Date Revision Author HeadURL Id Modified: leto/jiemamy-commons/trunk/LICENSE.txt =================================================================== --- leto/jiemamy-commons/trunk/LICENSE.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/LICENSE.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. Property changes on: leto/jiemamy-commons/trunk/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/license/LICENSE.hamcrest.txt =================================================================== --- leto/jiemamy-commons/trunk/license/LICENSE.hamcrest.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/license/LICENSE.hamcrest.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,27 +1,27 @@ -BSD License - -Copyright (c) 2000-2006, www.hamcrest.org -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of -conditions and the following disclaimer. Redistributions in binary form must reproduce -the above copyright notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -Neither the name of Hamcrest nor the names of its contributors may be used to endorse -or promote products derived from this software without specific prior written -permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT -SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY -WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. +BSD License + +Copyright (c) 2000-2006, www.hamcrest.org +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. Redistributions in binary form must reproduce +the above copyright notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the distribution. + +Neither the name of Hamcrest nor the names of its contributors may be used to endorse +or promote products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. Property changes on: leto/jiemamy-commons/trunk/license/LICENSE.hamcrest.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/jiemamy-commons/trunk/license/LICENSE.junit.html ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/html Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/license/LICENSE.logback.txt =================================================================== --- leto/jiemamy-commons/trunk/license/LICENSE.logback.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/license/LICENSE.logback.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,22 +1,22 @@ -Logback LICENSE ---------------- - -Logback: the reliable, generic, fast and flexible logging library for -Java. - -Copyright (C) 2000-2008, QOS.ch - -Source code and binaries for logback, including logback-core, -logback-classic and logback-access modules, are distributed under the -GNU Lesser General Public License Version 2.1, as published by the -Free Software Foundation. - -This library 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 2.1 of the -License, or (at your option) any later version. - -This library 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. +Logback LICENSE +--------------- + +Logback: the reliable, generic, fast and flexible logging library for +Java. + +Copyright (C) 2000-2008, QOS.ch + +Source code and binaries for logback, including logback-core, +logback-classic and logback-access modules, are distributed under the +GNU Lesser General Public License Version 2.1, as published by the +Free Software Foundation. + +This library 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 2.1 of the +License, or (at your option) any later version. + +This library 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. Property changes on: leto/jiemamy-commons/trunk/license/LICENSE.logback.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/license/LICENSE.slf4j.txt =================================================================== --- leto/jiemamy-commons/trunk/license/LICENSE.slf4j.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/license/LICENSE.slf4j.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,24 +1,24 @@ -Copyright (c) 2004-2008 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - +Copyright (c) 2004-2008 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + Property changes on: leto/jiemamy-commons/trunk/license/LICENSE.slf4j.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/license/list.txt =================================================================== --- leto/jiemamy-commons/trunk/license/list.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/license/list.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,14 +1,14 @@ -MIT License: - SLF4J API Module, - JCL 1.1.1 implemented over SLF4J - -BSD style: - Hamcrest Core, - Hamcrest Library, - -Common Public License Version 1.0: - JUnit - -GNU Lesser General Public License: - Logback Classic Module, - Logback Core Module +MIT License: + SLF4J API Module, + JCL 1.1.1 implemented over SLF4J + +BSD style: + Hamcrest Core, + Hamcrest Library, + +Common Public License Version 1.0: + JUnit + +GNU Lesser General Public License: + Logback Classic Module, + Logback Core Module Property changes on: leto/jiemamy-commons/trunk/license/list.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/pom.xml =================================================================== --- leto/jiemamy-commons/trunk/pom.xml 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/pom.xml 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,122 +1,122 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.jiemamy</groupId> - <artifactId>master</artifactId> - <version>1.1</version> - </parent> - <groupId>org.jiemamy</groupId> - <artifactId>jiemamy-commons</artifactId> - <name>Jiemamy Commons</name> - <version>0.0.4-SNAPSHOT</version> - <url>http://report.jiemamy.org/jiemamy-commons</url> - <issueManagement> - <system>JIRA</system> - <url>http://jira.jiemamy.org/jira/browse/COM</url> - </issueManagement> - <ciManagement> - <system>hudson</system> - <url>http://hudson.jiemamy.org/hudson/job/jiemamy-commons/</url> - <notifiers> - <notifier> - <sendOnSuccess>false</sendOnSuccess> - <configuration> - <recipients>jiema****@googl*****</recipients> - </configuration> - </notifier> - </notifiers> - </ciManagement> - <inceptionYear>2009</inceptionYear> - <developers> - <developer> - <id>daisuke</id> - <name>MIYAMOTO Daisuke</name> - <email>daisuke_m****@users*****</email> - <url>http://d.hatena.ne.jp/daisuke-m/</url> - <timezone>+9</timezone> - </developer> - <developer> - <id>j5ik2o</id> - <name>Junichi Kato</name> - <email>j5ik2****@users*****</email> - <url>http://d.hatena.ne.jp/j5ik2o/</url> - <timezone>+9</timezone> - </developer> - </developers> - <scm> - <connection>scm:svn:http://svn.sourceforge.jp/svnroot/jiemamy/leto/jiemamy-commons/trunk</connection> - <developerConnection>scm:svn:svn+ssh://svn.sourceforge.jp/svnroot/jiemamy/leto/jiemamy-commons/trunk</developerConnection> - <url>http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi/leto/jiemamy-commons/trunk/?root=jiemamy</url> - </scm> - <repositories> - <repository> - <id>jiemamy.org</id> - <name>Jiemamy Repository</name> - <url>http://maven.jiemamy.org/release</url> - </repository> - </repositories> - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.5</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <version>1.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <version>1.1.113</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>1.5.6</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> - <version>1.5.6</version> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-core</artifactId> - <version>0.9.15</version> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <version>0.9.15</version> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.4</version> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>1.3.2</version> - </dependency> - <dependency> - <groupId>net.sourceforge.collections</groupId> - <artifactId>collections-generic</artifactId> - <version>4.01</version> - </dependency> - <dependency> - <groupId>javassist</groupId> - <artifactId>javassist</artifactId> - <version>3.8.0.GA</version> - <optional>false</optional> - </dependency> - </dependencies> +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.jiemamy</groupId> + <artifactId>master</artifactId> + <version>1.1</version> + </parent> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-commons</artifactId> + <name>Jiemamy Commons</name> + <version>0.0.4-SNAPSHOT</version> + <url>http://report.jiemamy.org/jiemamy-commons</url> + <issueManagement> + <system>JIRA</system> + <url>http://jira.jiemamy.org/jira/browse/COM</url> + </issueManagement> + <ciManagement> + <system>hudson</system> + <url>http://hudson.jiemamy.org/hudson/job/jiemamy-commons/</url> + <notifiers> + <notifier> + <sendOnSuccess>false</sendOnSuccess> + <configuration> + <recipients>jiema****@googl*****</recipients> + </configuration> + </notifier> + </notifiers> + </ciManagement> + <inceptionYear>2009</inceptionYear> + <developers> + <developer> + <id>daisuke</id> + <name>MIYAMOTO Daisuke</name> + <email>daisuke_m****@users*****</email> + <url>http://d.hatena.ne.jp/daisuke-m/</url> + <timezone>+9</timezone> + </developer> + <developer> + <id>j5ik2o</id> + <name>Junichi Kato</name> + <email>j5ik2****@users*****</email> + <url>http://d.hatena.ne.jp/j5ik2o/</url> + <timezone>+9</timezone> + </developer> + </developers> + <scm> + <connection>scm:svn:http://svn.sourceforge.jp/svnroot/jiemamy/leto/jiemamy-commons/trunk</connection> + <developerConnection>scm:svn:svn+ssh://svn.sourceforge.jp/svnroot/jiemamy/leto/jiemamy-commons/trunk</developerConnection> + <url>http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi/leto/jiemamy-commons/trunk/?root=jiemamy</url> + </scm> + <repositories> + <repository> + <id>jiemamy.org</id> + <name>Jiemamy Repository</name> + <url>http://maven.jiemamy.org/release</url> + </repository> + </repositories> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-library</artifactId> + <version>1.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <version>1.1.113</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.5.6</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>1.5.6</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>0.9.15</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>0.9.15</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.4</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>1.3.2</version> + </dependency> + <dependency> + <groupId>net.sourceforge.collections</groupId> + <artifactId>collections-generic</artifactId> + <version>4.01</version> + </dependency> + <dependency> + <groupId>javassist</groupId> + <artifactId>javassist</artifactId> + <version>3.8.0.GA</version> + <optional>false</optional> + </dependency> + </dependencies> </project> \ No newline at end of file Property changes on: leto/jiemamy-commons/trunk/pom.xml ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/exception/JiemamyError.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/exception/JiemamyError.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/exception/JiemamyError.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,56 +1,56 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/01 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.exception; - -/** - * Jiemamyの実装バグが原因であることによるエラー。 - * - * <ul> - * <li>http://d.hatena.ne.jp/daisuke-m/20081201/1228095493</li> - * <li>http://d.hatena.ne.jp/daisuke-m/20081202/1228221927</li> - * </ul> - * - * @since 0.2 - * @author daisuke - */ - @ SuppressWarnings("serial") -public class JiemamyError extends Error { - - /** - * インスタンスを生成する。 - * - * @param message 例外メッセージ(エラーが発生した状況、考えられる原因など、なるべく詳細に記載すること) - * @since 0.2 - */ - public JiemamyError(String message) { - super(message); - } - - /** - * インスタンスを生成する。 - * - * @param message 例外メッセージ(エラーが発生した状況、考えられる原因など、なるべく詳細に記載すること) - * @param cause 起因例外 - * @since 0.2 - */ - public JiemamyError(String message, Throwable cause) { - super(message, cause); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/01 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.exception; + +/** + * Jiemamyの実装バグが原因であることによるエラー。 + * + * <ul> + * <li>http://d.hatena.ne.jp/daisuke-m/20081201/1228095493</li> + * <li>http://d.hatena.ne.jp/daisuke-m/20081202/1228221927</li> + * </ul> + * + * @since 0.2 + * @author daisuke + */ + @ SuppressWarnings("serial") +public class JiemamyError extends Error { + + /** + * インスタンスを生成する。 + * + * @param message 例外メッセージ(エラーが発生した状況、考えられる原因など、なるべく詳細に記載すること) + * @since 0.2 + */ + public JiemamyError(String message) { + super(message); + } + + /** + * インスタンスを生成する。 + * + * @param message 例外メッセージ(エラーが発生した状況、考えられる原因など、なるべく詳細に記載すること) + * @param cause 起因例外 + * @since 0.2 + */ + public JiemamyError(String message, Throwable cause) { + super(message, cause); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/exception/JiemamyError.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/AnnotationUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/AnnotationUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/AnnotationUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,60 +1,60 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/02/04 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.lang.annotation.Annotation; - -import org.apache.commons.lang.Validate; - -/** - * アノテーションを処理するユーティリティクラス。 - * - * @author daisuke - */ -public class AnnotationUtil { - - /** - * target自身の型、及びそのインターフェイスのいずれかが持つアノテーションを取得する。 - * - * @param <T> アノテーションの型 - * @param target 調査対象オブジェクト - * @param annotationClass アノテーションの型 - * @return 取得したアノテーション - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static <T extends Annotation>T getTypeAnnotation(Object target, Class<T> annotationClass) { - Validate.notNull(target); - Validate.notNull(annotationClass); - - Annotation classAnnotation = target.getClass().getAnnotation(annotationClass); - if (classAnnotation != null) { - return annotationClass.cast(classAnnotation); - } - for (Class<?> interf : target.getClass().getInterfaces()) { - Annotation interfaceAnnotation = interf.getAnnotation(annotationClass); - if (interfaceAnnotation != null) { - return annotationClass.cast(interfaceAnnotation); - } - } - return null; - } - - private AnnotationUtil() { - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/04 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.lang.annotation.Annotation; + +import org.apache.commons.lang.Validate; + +/** + * アノテーションを処理するユーティリティクラス。 + * + * @author daisuke + */ +public class AnnotationUtil { + + /** + * target自身の型、及びそのインターフェイスのいずれかが持つアノテーションを取得する。 + * + * @param <T> アノテーションの型 + * @param target 調査対象オブジェクト + * @param annotationClass アノテーションの型 + * @return 取得したアノテーション + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static <T extends Annotation>T getTypeAnnotation(Object target, Class<T> annotationClass) { + Validate.notNull(target); + Validate.notNull(annotationClass); + + Annotation classAnnotation = target.getClass().getAnnotation(annotationClass); + if (classAnnotation != null) { + return annotationClass.cast(classAnnotation); + } + for (Class<?> interf : target.getClass().getInterfaces()) { + Annotation interfaceAnnotation = interf.getAnnotation(annotationClass); + if (interfaceAnnotation != null) { + return annotationClass.cast(interfaceAnnotation); + } + } + return null; + } + + private AnnotationUtil() { + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/AnnotationUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ArrayEssentialStack.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ArrayEssentialStack.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ArrayEssentialStack.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,148 +1,148 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/16 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.Collection; -import java.util.Iterator; - -import org.apache.commons.collections15.ArrayStack; -import org.apache.commons.lang.Validate; - -/** - * {@link EssentialStack}の{@link ArrayStack}を用いた実装。 - * - * @param <E> 要素の型 - * @author daisuke - */ -public class ArrayEssentialStack<E> implements EssentialStack<E> { - - /** 10% room for growth */ - private static final double GROWTH_FACTOR = 1.1; - - private final ArrayStack<E> stack; - - - /** - * インスタンスを生成する。 - */ - public ArrayEssentialStack() { - stack = new ArrayStack<E>(); - } - - /** - * インスタンスを生成する。 - * - * @param collection 初期要素を保持したコレクション - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public ArrayEssentialStack(Collection<? extends E> collection) { - Validate.notNull(collection); - int size = collection.size(); - int capacity = (int) Math.min(size * GROWTH_FACTOR, Integer.MAX_VALUE); - - stack = new ArrayStack<E>(capacity); - for (E element : collection) { - stack.push(element); - } - } - - /** - * インスタンスを生成する。 - * - * @param source 初期要素を保持したスタック - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public ArrayEssentialStack(EssentialStack<? extends E> source) { - Validate.notNull(source); - stack = new ArrayStack<E>(source.size()); - for (E element : source) { - stack.push(element); - } - } - - /** - * インスタンスを生成する。 - * - * @param initialSize 初期サイズ - */ - public ArrayEssentialStack(int initialSize) { - stack = new ArrayStack<E>(initialSize); - } - - public void clear() { - stack.clear(); - } - - public E get(int n) { - return stack.get(n); - } - - public void insert(int index, E element) { - stack.add(index, element); - } - - public boolean isEmpty() { - return stack.isEmpty(); - } - - public Iterator<E> iterator() { - return stack.iterator(); - } - - public E peek() { - return stack.peek(); - } - - public E peek(int n) { - return stack.peek(n); - } - - public E pop() { - return stack.pop(); - } - - public void push(E element) { - stack.push(element); - } - - public boolean remove(E element) { - return stack.remove(element); - } - - public E remove(int n) { - return stack.remove(n); - } - - public EssentialStack<E> reverse() { - EssentialStack<E> result = new ArrayEssentialStack<E>(stack.size()); - for (E element : stack) { - result.insert(0, element); - } - return result; - } - - public int size() { - return stack.size(); - } - - @Override - public String toString() { - return stack.toString(); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/16 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.Collection; +import java.util.Iterator; + +import org.apache.commons.collections15.ArrayStack; +import org.apache.commons.lang.Validate; + +/** + * {@link EssentialStack}の{@link ArrayStack}を用いた実装。 + * + * @param <E> 要素の型 + * @author daisuke + */ +public class ArrayEssentialStack<E> implements EssentialStack<E> { + + /** 10% room for growth */ + private static final double GROWTH_FACTOR = 1.1; + + private final ArrayStack<E> stack; + + + /** + * インスタンスを生成する。 + */ + public ArrayEssentialStack() { + stack = new ArrayStack<E>(); + } + + /** + * インスタンスを生成する。 + * + * @param collection 初期要素を保持したコレクション + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public ArrayEssentialStack(Collection<? extends E> collection) { + Validate.notNull(collection); + int size = collection.size(); + int capacity = (int) Math.min(size * GROWTH_FACTOR, Integer.MAX_VALUE); + + stack = new ArrayStack<E>(capacity); + for (E element : collection) { + stack.push(element); + } + } + + /** + * インスタンスを生成する。 + * + * @param source 初期要素を保持したスタック + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public ArrayEssentialStack(EssentialStack<? extends E> source) { + Validate.notNull(source); + stack = new ArrayStack<E>(source.size()); + for (E element : source) { + stack.push(element); + } + } + + /** + * インスタンスを生成する。 + * + * @param initialSize 初期サイズ + */ + public ArrayEssentialStack(int initialSize) { + stack = new ArrayStack<E>(initialSize); + } + + public void clear() { + stack.clear(); + } + + public E get(int n) { + return stack.get(n); + } + + public void insert(int index, E element) { + stack.add(index, element); + } + + public boolean isEmpty() { + return stack.isEmpty(); + } + + public Iterator<E> iterator() { + return stack.iterator(); + } + + public E peek() { + return stack.peek(); + } + + public E peek(int n) { + return stack.peek(n); + } + + public E pop() { + return stack.pop(); + } + + public void push(E element) { + stack.push(element); + } + + public boolean remove(E element) { + return stack.remove(element); + } + + public E remove(int n) { + return stack.remove(n); + } + + public EssentialStack<E> reverse() { + EssentialStack<E> result = new ArrayEssentialStack<E>(stack.size()); + for (E element : stack) { + result.insert(0, element); + } + return result; + } + + public int size() { + return stack.size(); + } + + @Override + public String toString() { + return stack.toString(); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ArrayEssentialStack.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ArrayMap.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ArrayMap.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ArrayMap.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,185 +1,185 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 8, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - -/** - * リストのような属性を持つマップクラス。 - * - * @param <K> キーの型 - * @param <V> 値の型 - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class ArrayMap<K, V> extends HashMap<K, V> { - - private List<V> valueList = CollectionsUtil.newArrayList(); - - - /** - * インスタンスを生成する。 - * - */ - public ArrayMap() { - - } - - /** - * インスタンスを生成する。 - * - * @param capacity キャパシティ - */ - public ArrayMap(int capacity) { - super(capacity); - valueList = CollectionsUtil.newArrayList(capacity); - } - - /** - * @see List#contains(Object) - * - * @param o List#contains(Object)の引数 - * @return List#contains(Object)の戻り値 - */ - public boolean contains(Object o) { - return valueList.contains(o); - } - - /** - * @see List#containsAll(Collection) - * - * @param c List#containsAll(Collection)の引数 - * @return List#containsAll(Collection)の戻り値 - */ - public boolean containsAll(Collection<?> c) { - return valueList.containsAll(c); - } - - /** - * @see List#get(int) - * - * @param index List#get(int)の引数 - * @return List#get(int)の戻り値 - */ - public V get(int index) { - return valueList.get(index); - } - - /** - * @see List#indexOf(Object) - * - * @param o {@link List#indexOf(Object)}の引数 - * @return {@link List#indexOf(Object)}の戻り値 - */ - public int indexOf(Object o) { - return valueList.indexOf(o); - } - - /** - * @see List#iterator() - * - * @return {@link List#iterator()}の戻り値 - */ - public Iterator<V> iterator() { - return valueList.iterator(); - } - - /** - * @see List#lastIndexOf(Object) - * - * @param o {@link List#lastIndexOf(Object)}の引数 - * @return {@link List#lastIndexOf(Object)}の戻り値 - */ - public int lastIndexOf(Object o) { - return valueList.lastIndexOf(o); - } - - /** - * @see List#listIterator() - * - * @return {@link List#listIterator()}の戻り値 - */ - public ListIterator<V> listIterator() { - return valueList.listIterator(); - } - - /** - * @see List#listIterator(int) - * - * @param index {@link List#listIterator(int)}の引数 - * @return {@link List#listIterator(int)}の戻り値 - */ - public ListIterator<V> listIterator(int index) { - return valueList.listIterator(index); - } - - @Override - public V put(K key, V value) { - V result = super.put(key, value); - valueList.add(value); - return result; - } - - @Override - public V remove(Object key) { - V result = super.remove(key); - if (result != null) { - valueList.remove(result); - } - return result; - } - - /** - * @see List#subList(int, int) - * - * @param fromIndex {@link List#subList(int, int)}の引数 - * @param toIndex {@link List#subList(int, int)}の引数 - * @return {@link List#subList(int, int)}の戻り値 - */ - public List<V> subList(int fromIndex, int toIndex) { - return valueList.subList(fromIndex, toIndex); - } - - /** - * @see List#toArray() - * - * @param <T> {@link List#toArray()}の戻り値の型 - * @return {@link List#toArray()}の戻り値 - */ - @SuppressWarnings("unchecked") - public <T>T[] toArray() { - return (T[]) valueList.toArray(); - } - - /** - * @see List#toArray(Object[]) - * - * @param <T> {@link List#toArray(Object[])}の戻り値の型 - * @param values {@link List#toArray(Object[])}の引数 - * @return {@link List#toArray(Object[])}の戻り値 - */ - public <T>T[] toArray(T[] values) { - return valueList.toArray(values); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 8, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +/** + * リストのような属性を持つマップクラス。 + * + * @param <K> キーの型 + * @param <V> 値の型 + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class ArrayMap<K, V> extends HashMap<K, V> { + + private List<V> valueList = CollectionsUtil.newArrayList(); + + + /** + * インスタンスを生成する。 + * + */ + public ArrayMap() { + + } + + /** + * インスタンスを生成する。 + * + * @param capacity キャパシティ + */ + public ArrayMap(int capacity) { + super(capacity); + valueList = CollectionsUtil.newArrayList(capacity); + } + + /** + * @see List#contains(Object) + * + * @param o List#contains(Object)の引数 + * @return List#contains(Object)の戻り値 + */ + public boolean contains(Object o) { + return valueList.contains(o); + } + + /** + * @see List#containsAll(Collection) + * + * @param c List#containsAll(Collection)の引数 + * @return List#containsAll(Collection)の戻り値 + */ + public boolean containsAll(Collection<?> c) { + return valueList.containsAll(c); + } + + /** + * @see List#get(int) + * + * @param index List#get(int)の引数 + * @return List#get(int)の戻り値 + */ + public V get(int index) { + return valueList.get(index); + } + + /** + * @see List#indexOf(Object) + * + * @param o {@link List#indexOf(Object)}の引数 + * @return {@link List#indexOf(Object)}の戻り値 + */ + public int indexOf(Object o) { + return valueList.indexOf(o); + } + + /** + * @see List#iterator() + * + * @return {@link List#iterator()}の戻り値 + */ + public Iterator<V> iterator() { + return valueList.iterator(); + } + + /** + * @see List#lastIndexOf(Object) + * + * @param o {@link List#lastIndexOf(Object)}の引数 + * @return {@link List#lastIndexOf(Object)}の戻り値 + */ + public int lastIndexOf(Object o) { + return valueList.lastIndexOf(o); + } + + /** + * @see List#listIterator() + * + * @return {@link List#listIterator()}の戻り値 + */ + public ListIterator<V> listIterator() { + return valueList.listIterator(); + } + + /** + * @see List#listIterator(int) + * + * @param index {@link List#listIterator(int)}の引数 + * @return {@link List#listIterator(int)}の戻り値 + */ + public ListIterator<V> listIterator(int index) { + return valueList.listIterator(index); + } + + @Override + public V put(K key, V value) { + V result = super.put(key, value); + valueList.add(value); + return result; + } + + @Override + public V remove(Object key) { + V result = super.remove(key); + if (result != null) { + valueList.remove(result); + } + return result; + } + + /** + * @see List#subList(int, int) + * + * @param fromIndex {@link List#subList(int, int)}の引数 + * @param toIndex {@link List#subList(int, int)}の引数 + * @return {@link List#subList(int, int)}の戻り値 + */ + public List<V> subList(int fromIndex, int toIndex) { + return valueList.subList(fromIndex, toIndex); + } + + /** + * @see List#toArray() + * + * @param <T> {@link List#toArray()}の戻り値の型 + * @return {@link List#toArray()}の戻り値 + */ + @SuppressWarnings("unchecked") + public <T>T[] toArray() { + return (T[]) valueList.toArray(); + } + + /** + * @see List#toArray(Object[]) + * + * @param <T> {@link List#toArray(Object[])}の戻り値の型 + * @param values {@link List#toArray(Object[])}の引数 + * @return {@link List#toArray(Object[])}の戻り値 + */ + public <T>T[] toArray(T[] values) { + return valueList.toArray(values); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ArrayMap.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassLoaderUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassLoaderUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassLoaderUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,290 +1,290 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URL; -import java.util.Enumeration; -import java.util.Iterator; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link ClassLoader}を扱うためのユーティリティクラス。 - * - * @author j5ik2o - */ -public class ClassLoaderUtil { - - private static final Method FIND_LOADED_CLASS_METHOD = getFindLoadedClassMethod(); - - private static final Method DEFINE_CLASS_METHOD = getDefineClassMethod(); - - private static final Method DEFINE_PACKAGE_METHOD = getDefinePackageMethod(); - - - /** - * バイトの配列を<code>Class</code>クラスのインスタンスに変換する。 - * - * @param classLoader バイナリデータから<code>Class</code>クラスのインスタンスに変換するクラスローダ - * @param className クラスのバイナリ名 - * @param bytes クラスデータを構成するバイト列 - * @param offset クラスデータ<code>bytes</code>の開始オフセット - * @param length クラスデータの長さ - * @return 指定されたクラスデータから作成された<code>Class</code>オブジェクト - * @throws InvocationTargetException メソッドが例外をスローする場合 - * @throws IllegalAccessException メソッドにアクセスできない場合 - * @throws IllegalArgumentException 引数が正しくない場合 - */ - public static Class<?> defineClass(final ClassLoader classLoader, final String className, final byte[] bytes, - final int offset, final int length) throws IllegalArgumentException, IllegalAccessException, - InvocationTargetException { - return (Class<?>) MethodUtil.invoke(DEFINE_CLASS_METHOD, classLoader, new Object[] { - className, - bytes, - Integer.valueOf(offset), - Integer.valueOf(length) - }); - } - - /** - * 指定の<code>ClassLoader</code>で名前を使ってパッケージを定義する。 - * - * @param classLoader パッケージを定義するクラスローダ - * @param name パッケージ名 - * @param specTitle 仕様のタイトル - * @param specVersion 仕様のバージョン - * @param specVendor 仕様のベンダー - * @param implTitle 実装のタイトル - * @param implVersion 実装のバージョン - * @param implVendor 実装のベンダー - * @param sealBase <code>null</code>でない場合、このパッケージは指定されたコードソース<code>URL</code>オブジェクトを考慮してシールされる。そうでない場合、パッケージはシールされない - * @return 新しく定義された<code>Package</code>オブジェクト - * @throws InvocationTargetException メソッドが例外をスローする場合 - * @throws IllegalAccessException メソッドにアクセスできない場合 - * @throws IllegalArgumentException 引数が正しくない場合 - */ - // CHECKSTYLE:OFF - public static Package definePackage(final ClassLoader classLoader, final String name, final String specTitle, - final String specVersion, final String specVendor, final String implTitle, final String implVersion, - final String implVendor, final URL sealBase) throws IllegalArgumentException, IllegalAccessException, - InvocationTargetException { - return (Package) MethodUtil.invoke(DEFINE_PACKAGE_METHOD, classLoader, new Object[] { - name, - specTitle, - specVersion, - specVendor, - implTitle, - implVersion, - implVendor, - sealBase - }); - } - - // CHECKSTYLE:ON - - /** - * 指定のクラスローダまたはその祖先のクラスローダが、 このバイナリ名を持つクラスの起動ローダとしてJava仮想マシンにより記録されていた場合は、 - * 指定されたバイナリ名を持つクラスを取得する。 記録されていなかった場合は<code>null</code>を取得する。 - * - * @param classLoader クラスローダ - * @param className クラスのバイナリ名 - * @return <code>Class</code>オブジェクト。クラスがロードされていない場合は<code>null</code> - * @throws InvocationTargetException メソッドが例外をスローする場合 - * @throws IllegalAccessException メソッドにアクセスできない場合 - * @throws IllegalArgumentException 引数が正しくない場合 - */ - public static Class<?> findLoadedClass(final ClassLoader classLoader, final String className) - throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { - for (ClassLoader loader = classLoader; loader != null; loader = loader.getParent()) { - final Class<?> clazz = (Class<?>) MethodUtil.invoke(FIND_LOADED_CLASS_METHOD, loader, new Object[] { - className - }); - if (clazz != null) { - return clazz; - } - } - return null; - } - - /** - * クラスローダを取得する。 - * - * @param targetClass ターゲット・クラス - * @return クラスローダ - */ - public static ClassLoader getClassLoader(final Class<?> targetClass) { - final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); - if (contextClassLoader != null) { - return contextClassLoader; - } - - final ClassLoader targetClassLoader = targetClass.getClassLoader(); - final ClassLoader thisClassLoader = ClassLoaderUtil.class.getClassLoader(); - if (targetClassLoader != null && thisClassLoader != null) { - if (isAncestor(thisClassLoader, targetClassLoader)) { - return thisClassLoader; - } - return targetClassLoader; - } - if (targetClassLoader != null) { - return targetClassLoader; - } - if (thisClassLoader != null) { - return thisClassLoader; - } - - final ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); - if (systemClassLoader != null) { - return systemClassLoader; - } - - throw new IllegalStateException(); - } - - /** - * {@link #getClassLoader(Class)}が返すクラスローダから指定された名前を持つすべてのリソースを検索する。 - * - * @param targetClass ターゲット・クラス - * @param name リソース名 - * @return リソースに対するURL。オブジェクトの列挙。リソースが見つからなかった場合、列挙は空になる。クラスローダがアクセスを持たないリソースは列挙に入らない - * @throws IOException IOException 入出力エラーが発生した場合 - * @see java.lang.ClassLoader#getResources(String) - */ - public static Iterator<?> getResources(final Class<?> targetClass, final String name) throws IOException { - return getResources(getClassLoader(targetClass), name); - } - - /** - * 指定のクラスローダから指定された名前を持つすべてのリソースを検索する。 - * - * @param loader クラスローダ - * @param name リソース名 - * @return リソースに対するURL。オブジェクトの列挙。リソースが見つからなかった場合、列挙は空になる。クラスローダがアクセスを持たないリソースは列挙に入らない - * @throws IOException 入出力エラーが発生した場合 - */ - public static Iterator<URL> getResources(final ClassLoader loader, final String name) throws IOException { - - final Enumeration<URL> e = loader.getResources(name); - return new EnumerationIterator<URL>(e); - - } - - /** - * コンテキストクラスローダから指定された名前を持つすべてのリソースを検索する。 - * - * @param name リソース名 - * @return リソースに対するURL。オブジェクトの列挙。リソースが見つからなかった場合、列挙は空になる。クラスローダがアクセスを持たないリソースは列挙に入らない - * @throws IOException 入出力エラーが発生した場合 - */ - public static Iterator<URL> getResources(final String name) throws IOException { - return getResources(Thread.currentThread().getContextClassLoader(), name); - } - - /** - * 指定されたバイナリ名を持つクラスをロードする。 - * - * @param loader クラスローダ - * @param className クラスのバイナリ名 - * @return 結果の<code>Class</code>オブジェクト - * @throws ClassNotFoundException クラスが見つからなかった場合 - */ - public static Class<?> loadClass(final ClassLoader loader, final String className) throws ClassNotFoundException { - return loader.loadClass(className); - } - - /** - * クラスローダ<code>other</code>がクラスローダ<code>cl</code>の祖先なら<code>true</code>を取得する。 - * - * @param cl クラスローダ - * @param other クラスローダ - * @return クラスローダ<code>other</code>がクラスローダ<code>cl</code>の祖先なら<code>true</code> - */ - protected static boolean isAncestor(ClassLoader cl, final ClassLoader other) { - ClassLoader current = cl; - while (current != null) { - if (current == other) { - return true; - } - current = current.getParent(); - } - return false; - } - - private static Method getDefineClassMethod() { - try { - Method method = ClassUtil.getDeclaredMethod(ClassLoader.class, "defineClass", new Class[] { - String.class, - byte[].class, - int.class, - int.class - }); - method.setAccessible(true); - return method; - } catch (SecurityException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } - return null; - } - - private static Method getDefinePackageMethod() { - try { - Method method = ClassUtil.getDeclaredMethod(ClassLoader.class, "definePackage", new Class[] { - String.class, - String.class, - String.class, - String.class, - String.class, - String.class, - String.class, - URL.class - }); - method.setAccessible(true); - return method; - } catch (SecurityException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } - return null; - } - - private static Method getFindLoadedClassMethod() { - try { - Method method = ClassUtil.getDeclaredMethod(ClassLoader.class, "findLoadedClass", new Class[] { - String.class - }); - method.setAccessible(true); - return method; - } catch (SecurityException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } - return null; - } - - private ClassLoaderUtil() { - throw new JiemamyError("不到達ポイント"); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URL; +import java.util.Enumeration; +import java.util.Iterator; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link ClassLoader}を扱うためのユーティリティクラス。 + * + * @author j5ik2o + */ +public class ClassLoaderUtil { + + private static final Method FIND_LOADED_CLASS_METHOD = getFindLoadedClassMethod(); + + private static final Method DEFINE_CLASS_METHOD = getDefineClassMethod(); + + private static final Method DEFINE_PACKAGE_METHOD = getDefinePackageMethod(); + + + /** + * バイトの配列を<code>Class</code>クラスのインスタンスに変換する。 + * + * @param classLoader バイナリデータから<code>Class</code>クラスのインスタンスに変換するクラスローダ + * @param className クラスのバイナリ名 + * @param bytes クラスデータを構成するバイト列 + * @param offset クラスデータ<code>bytes</code>の開始オフセット + * @param length クラスデータの長さ + * @return 指定されたクラスデータから作成された<code>Class</code>オブジェクト + * @throws InvocationTargetException メソッドが例外をスローする場合 + * @throws IllegalAccessException メソッドにアクセスできない場合 + * @throws IllegalArgumentException 引数が正しくない場合 + */ + public static Class<?> defineClass(final ClassLoader classLoader, final String className, final byte[] bytes, + final int offset, final int length) throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException { + return (Class<?>) MethodUtil.invoke(DEFINE_CLASS_METHOD, classLoader, new Object[] { + className, + bytes, + Integer.valueOf(offset), + Integer.valueOf(length) + }); + } + + /** + * 指定の<code>ClassLoader</code>で名前を使ってパッケージを定義する。 + * + * @param classLoader パッケージを定義するクラスローダ + * @param name パッケージ名 + * @param specTitle 仕様のタイトル + * @param specVersion 仕様のバージョン + * @param specVendor 仕様のベンダー + * @param implTitle 実装のタイトル + * @param implVersion 実装のバージョン + * @param implVendor 実装のベンダー + * @param sealBase <code>null</code>でない場合、このパッケージは指定されたコードソース<code>URL</code>オブジェクトを考慮してシールされる。そうでない場合、パッケージはシールされない + * @return 新しく定義された<code>Package</code>オブジェクト + * @throws InvocationTargetException メソッドが例外をスローする場合 + * @throws IllegalAccessException メソッドにアクセスできない場合 + * @throws IllegalArgumentException 引数が正しくない場合 + */ + // CHECKSTYLE:OFF + public static Package definePackage(final ClassLoader classLoader, final String name, final String specTitle, + final String specVersion, final String specVendor, final String implTitle, final String implVersion, + final String implVendor, final URL sealBase) throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException { + return (Package) MethodUtil.invoke(DEFINE_PACKAGE_METHOD, classLoader, new Object[] { + name, + specTitle, + specVersion, + specVendor, + implTitle, + implVersion, + implVendor, + sealBase + }); + } + + // CHECKSTYLE:ON + + /** + * 指定のクラスローダまたはその祖先のクラスローダが、 このバイナリ名を持つクラスの起動ローダとしてJava仮想マシンにより記録されていた場合は、 + * 指定されたバイナリ名を持つクラスを取得する。 記録されていなかった場合は<code>null</code>を取得する。 + * + * @param classLoader クラスローダ + * @param className クラスのバイナリ名 + * @return <code>Class</code>オブジェクト。クラスがロードされていない場合は<code>null</code> + * @throws InvocationTargetException メソッドが例外をスローする場合 + * @throws IllegalAccessException メソッドにアクセスできない場合 + * @throws IllegalArgumentException 引数が正しくない場合 + */ + public static Class<?> findLoadedClass(final ClassLoader classLoader, final String className) + throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { + for (ClassLoader loader = classLoader; loader != null; loader = loader.getParent()) { + final Class<?> clazz = (Class<?>) MethodUtil.invoke(FIND_LOADED_CLASS_METHOD, loader, new Object[] { + className + }); + if (clazz != null) { + return clazz; + } + } + return null; + } + + /** + * クラスローダを取得する。 + * + * @param targetClass ターゲット・クラス + * @return クラスローダ + */ + public static ClassLoader getClassLoader(final Class<?> targetClass) { + final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + if (contextClassLoader != null) { + return contextClassLoader; + } + + final ClassLoader targetClassLoader = targetClass.getClassLoader(); + final ClassLoader thisClassLoader = ClassLoaderUtil.class.getClassLoader(); + if (targetClassLoader != null && thisClassLoader != null) { + if (isAncestor(thisClassLoader, targetClassLoader)) { + return thisClassLoader; + } + return targetClassLoader; + } + if (targetClassLoader != null) { + return targetClassLoader; + } + if (thisClassLoader != null) { + return thisClassLoader; + } + + final ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); + if (systemClassLoader != null) { + return systemClassLoader; + } + + throw new IllegalStateException(); + } + + /** + * {@link #getClassLoader(Class)}が返すクラスローダから指定された名前を持つすべてのリソースを検索する。 + * + * @param targetClass ターゲット・クラス + * @param name リソース名 + * @return リソースに対するURL。オブジェクトの列挙。リソースが見つからなかった場合、列挙は空になる。クラスローダがアクセスを持たないリソースは列挙に入らない + * @throws IOException IOException 入出力エラーが発生した場合 + * @see java.lang.ClassLoader#getResources(String) + */ + public static Iterator<?> getResources(final Class<?> targetClass, final String name) throws IOException { + return getResources(getClassLoader(targetClass), name); + } + + /** + * 指定のクラスローダから指定された名前を持つすべてのリソースを検索する。 + * + * @param loader クラスローダ + * @param name リソース名 + * @return リソースに対するURL。オブジェクトの列挙。リソースが見つからなかった場合、列挙は空になる。クラスローダがアクセスを持たないリソースは列挙に入らない + * @throws IOException 入出力エラーが発生した場合 + */ + public static Iterator<URL> getResources(final ClassLoader loader, final String name) throws IOException { + + final Enumeration<URL> e = loader.getResources(name); + return new EnumerationIterator<URL>(e); + + } + + /** + * コンテキストクラスローダから指定された名前を持つすべてのリソースを検索する。 + * + * @param name リソース名 + * @return リソースに対するURL。オブジェクトの列挙。リソースが見つからなかった場合、列挙は空になる。クラスローダがアクセスを持たないリソースは列挙に入らない + * @throws IOException 入出力エラーが発生した場合 + */ + public static Iterator<URL> getResources(final String name) throws IOException { + return getResources(Thread.currentThread().getContextClassLoader(), name); + } + + /** + * 指定されたバイナリ名を持つクラスをロードする。 + * + * @param loader クラスローダ + * @param className クラスのバイナリ名 + * @return 結果の<code>Class</code>オブジェクト + * @throws ClassNotFoundException クラスが見つからなかった場合 + */ + public static Class<?> loadClass(final ClassLoader loader, final String className) throws ClassNotFoundException { + return loader.loadClass(className); + } + + /** + * クラスローダ<code>other</code>がクラスローダ<code>cl</code>の祖先なら<code>true</code>を取得する。 + * + * @param cl クラスローダ + * @param other クラスローダ + * @return クラスローダ<code>other</code>がクラスローダ<code>cl</code>の祖先なら<code>true</code> + */ + protected static boolean isAncestor(ClassLoader cl, final ClassLoader other) { + ClassLoader current = cl; + while (current != null) { + if (current == other) { + return true; + } + current = current.getParent(); + } + return false; + } + + private static Method getDefineClassMethod() { + try { + Method method = ClassUtil.getDeclaredMethod(ClassLoader.class, "defineClass", new Class[] { + String.class, + byte[].class, + int.class, + int.class + }); + method.setAccessible(true); + return method; + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return null; + } + + private static Method getDefinePackageMethod() { + try { + Method method = ClassUtil.getDeclaredMethod(ClassLoader.class, "definePackage", new Class[] { + String.class, + String.class, + String.class, + String.class, + String.class, + String.class, + String.class, + URL.class + }); + method.setAccessible(true); + return method; + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return null; + } + + private static Method getFindLoadedClassMethod() { + try { + Method method = ClassUtil.getDeclaredMethod(ClassLoader.class, "findLoadedClass", new Class[] { + String.class + }); + method.setAccessible(true); + return method; + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return null; + } + + private ClassLoaderUtil() { + throw new JiemamyError("不到達ポイント"); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassLoaderUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassPoolUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassPoolUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassPoolUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,199 +1,199 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.Collections; -import java.util.Map; -import java.util.WeakHashMap; - -import javassist.ClassPool; -import javassist.CtClass; -import javassist.LoaderClassPath; -import javassist.NotFoundException; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.exception.JiemamyError; - -/** - * ClassPool用のユーティリティクラス。 - * - * @author j5ik2o - */ -public class ClassPoolUtil { - - /** - * ClassPoolのキャッシュ。 - */ - protected static final Map<ClassLoader, ClassPool> CLASS_POOL_MAP = - Collections.synchronizedMap(new WeakHashMap<ClassLoader, ClassPool>()); - - - /** - * {@link ClassPool}から{@link CtClass}を作成する。 - * - * @param classPool クラスプール - * @param name クラス名 - * @return CtClass - */ - public static CtClass createCtClass(final ClassPool classPool, final String name) { - try { - return createCtClass(classPool, name, Object.class); - } catch (NotFoundException e) { - throw new JiemamyError("不到達ポイント"); - } - } - - /** - * {@link ClassPool}から{@link CtClass}を作成する。 - * - * @param classPool クラスプール - * @param name クラス名 - * @param superClass スーパークラス - * @return {@link CtClass} - * @throws NotFoundException クラスプールにsuperClassが見つからなかった場合 - */ - public static CtClass createCtClass(final ClassPool classPool, final String name, final Class<?> superClass) - throws NotFoundException { - return createCtClass(classPool, name, toCtClass(classPool, superClass)); - } - - /** - * {@link ClassPool}に{@link CtClass}を作成します。 - * - * @param classPool クラスプール - * @param name クラス名 - * @param superClass スーパークラス - * @return {@link CtClass} - */ - public static CtClass createCtClass(final ClassPool classPool, final String name, final CtClass superClass) { - return classPool.makeClass(name, superClass); - } - - /** - * リソースを破棄します。 - */ - public static synchronized void dispose() { - synchronized (ClassPoolUtil.class) { - CLASS_POOL_MAP.clear(); - } - } - - /** - * ClassPoolを返します。 - * - * @param targetClass ターゲットクラス - * @return {@link ClassPool} - */ - public static ClassPool getClassPool(final Class<?> targetClass) { - return getClassPool(ClassLoaderUtil.getClassLoader(targetClass)); - } - - /** - * ClassPoolを返します。 - * - * @param classLoader クラスローダ - * @return {@link ClassPool} - */ - public static ClassPool getClassPool(final ClassLoader classLoader) { - Validate.notNull(classLoader); - ClassPool classPool = CLASS_POOL_MAP.get(classLoader); - if (classPool == null) { - if (classLoader == null) { - return ClassPool.getDefault(); - } - classPool = new ClassPool(); - classPool.appendClassPath(new LoaderClassPath(classLoader)); - CLASS_POOL_MAP.put(classLoader, classPool); - } - return classPool; - } - - /** - * CtClassに変換する。 - * - * @param classPool クラスプール - * @param clazz クラス - * @return {@link CtClass} - * @throws NotFoundException クラスプールにクラスが見つからなかった場合 - */ - public static CtClass toCtClass(final ClassPool classPool, final Class<?> clazz) throws NotFoundException { - Validate.notNull(classPool); - Validate.notNull(clazz); - return toCtClass(classPool, ClassUtil.getSimpleClassName(clazz)); - } - - /** - * CtClassに変換する。 - * - * @param classPool クラスプール - * @param className クラス名 - * @return {@link CtClass} - * @throws NotFoundException クラスプールにクラスが見つからなかった場合 - */ - public static CtClass toCtClass(final ClassPool classPool, final String className) throws NotFoundException { - Validate.notNull(classPool); - Validate.notNull(className); - return classPool.get(className); - } - - /** - * CtClassの配列に変換する。 - * - * @param classPool クラスプール - * @param classes クラス配列 - * @return CtClassの配列 - * @throws NotFoundException クラスプールにクラスが見つからなかった場合 - */ - public static CtClass[] toCtClassArray(final ClassPool classPool, final Class<?>[] classes) - throws NotFoundException { - if (classes == null) { - return new CtClass[0]; - } - final CtClass[] result = new CtClass[classes.length]; - for (int i = 0; i < result.length; ++i) { - result[i] = toCtClass(classPool, classes[i]); - } - return result; - } - - /** - * CtClassの配列に変換する。 - * - * @param classPool クラスプール - * @param classNames クラス名配列 - * @return CtClassの配列 - * @throws NotFoundException クラスプールにクラスが見つからなかった場合 - */ - public static CtClass[] toCtClassArray(final ClassPool classPool, final String[] classNames) - throws NotFoundException { - Validate.notNull(classNames); - if (classNames == null) { - return new CtClass[0]; - } - final CtClass[] result = new CtClass[classNames.length]; - for (int i = 0; i < result.length; ++i) { - result[i] = toCtClass(classPool, classNames[i]); - } - return result; - } - - private ClassPoolUtil() { - throw new JiemamyError("不到達ポイント"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.Collections; +import java.util.Map; +import java.util.WeakHashMap; + +import javassist.ClassPool; +import javassist.CtClass; +import javassist.LoaderClassPath; +import javassist.NotFoundException; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.exception.JiemamyError; + +/** + * ClassPool用のユーティリティクラス。 + * + * @author j5ik2o + */ +public class ClassPoolUtil { + + /** + * ClassPoolのキャッシュ。 + */ + protected static final Map<ClassLoader, ClassPool> CLASS_POOL_MAP = + Collections.synchronizedMap(new WeakHashMap<ClassLoader, ClassPool>()); + + + /** + * {@link ClassPool}から{@link CtClass}を作成する。 + * + * @param classPool クラスプール + * @param name クラス名 + * @return CtClass + */ + public static CtClass createCtClass(final ClassPool classPool, final String name) { + try { + return createCtClass(classPool, name, Object.class); + } catch (NotFoundException e) { + throw new JiemamyError("不到達ポイント"); + } + } + + /** + * {@link ClassPool}から{@link CtClass}を作成する。 + * + * @param classPool クラスプール + * @param name クラス名 + * @param superClass スーパークラス + * @return {@link CtClass} + * @throws NotFoundException クラスプールにsuperClassが見つからなかった場合 + */ + public static CtClass createCtClass(final ClassPool classPool, final String name, final Class<?> superClass) + throws NotFoundException { + return createCtClass(classPool, name, toCtClass(classPool, superClass)); + } + + /** + * {@link ClassPool}に{@link CtClass}を作成します。 + * + * @param classPool クラスプール + * @param name クラス名 + * @param superClass スーパークラス + * @return {@link CtClass} + */ + public static CtClass createCtClass(final ClassPool classPool, final String name, final CtClass superClass) { + return classPool.makeClass(name, superClass); + } + + /** + * リソースを破棄します。 + */ + public static synchronized void dispose() { + synchronized (ClassPoolUtil.class) { + CLASS_POOL_MAP.clear(); + } + } + + /** + * ClassPoolを返します。 + * + * @param targetClass ターゲットクラス + * @return {@link ClassPool} + */ + public static ClassPool getClassPool(final Class<?> targetClass) { + return getClassPool(ClassLoaderUtil.getClassLoader(targetClass)); + } + + /** + * ClassPoolを返します。 + * + * @param classLoader クラスローダ + * @return {@link ClassPool} + */ + public static ClassPool getClassPool(final ClassLoader classLoader) { + Validate.notNull(classLoader); + ClassPool classPool = CLASS_POOL_MAP.get(classLoader); + if (classPool == null) { + if (classLoader == null) { + return ClassPool.getDefault(); + } + classPool = new ClassPool(); + classPool.appendClassPath(new LoaderClassPath(classLoader)); + CLASS_POOL_MAP.put(classLoader, classPool); + } + return classPool; + } + + /** + * CtClassに変換する。 + * + * @param classPool クラスプール + * @param clazz クラス + * @return {@link CtClass} + * @throws NotFoundException クラスプールにクラスが見つからなかった場合 + */ + public static CtClass toCtClass(final ClassPool classPool, final Class<?> clazz) throws NotFoundException { + Validate.notNull(classPool); + Validate.notNull(clazz); + return toCtClass(classPool, ClassUtil.getSimpleClassName(clazz)); + } + + /** + * CtClassに変換する。 + * + * @param classPool クラスプール + * @param className クラス名 + * @return {@link CtClass} + * @throws NotFoundException クラスプールにクラスが見つからなかった場合 + */ + public static CtClass toCtClass(final ClassPool classPool, final String className) throws NotFoundException { + Validate.notNull(classPool); + Validate.notNull(className); + return classPool.get(className); + } + + /** + * CtClassの配列に変換する。 + * + * @param classPool クラスプール + * @param classes クラス配列 + * @return CtClassの配列 + * @throws NotFoundException クラスプールにクラスが見つからなかった場合 + */ + public static CtClass[] toCtClassArray(final ClassPool classPool, final Class<?>[] classes) + throws NotFoundException { + if (classes == null) { + return new CtClass[0]; + } + final CtClass[] result = new CtClass[classes.length]; + for (int i = 0; i < result.length; ++i) { + result[i] = toCtClass(classPool, classes[i]); + } + return result; + } + + /** + * CtClassの配列に変換する。 + * + * @param classPool クラスプール + * @param classNames クラス名配列 + * @return CtClassの配列 + * @throws NotFoundException クラスプールにクラスが見つからなかった場合 + */ + public static CtClass[] toCtClassArray(final ClassPool classPool, final String[] classNames) + throws NotFoundException { + Validate.notNull(classNames); + if (classNames == null) { + return new CtClass[0]; + } + final CtClass[] result = new CtClass[classNames.length]; + for (int i = 0; i < result.length; ++i) { + result[i] = toCtClass(classPool, classNames[i]); + } + return result; + } + + private ClassPoolUtil() { + throw new JiemamyError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassPoolUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassTraversal.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassTraversal.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassTraversal.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,141 +1,141 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.File; -import java.util.Enumeration; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - -import org.jiemamy.exception.JiemamyError; - -/** - * クラスを横断して処理するためのハンドらクラス。 - * - * @author j5ik2o - */ -public class ClassTraversal { - - /** - * クラスを横断して処理するためのハンドラインターフェイス。 - * - */ - public interface ClassHandler { - - /** - * クラスを処理する。 - * - * @param packageName パッケージ名 - * @param shortClassName クラス名 - * @throws TraversalHandlerException ハンドラの処理が失敗した場合 - */ - void processClass(String packageName, String shortClassName) throws TraversalHandlerException; - } - - - private static final String CLASS_SUFFIX = ".class"; - - private static final String WAR_FILE_EXTENSION = ".war"; - - private static final String WEB_INF_CLASSES_PATH = "WEB-INF/classes/"; - - - /** - * rootディレクトリ配下を処理します。 - * - * @param rootDir ルートディレクトリ - * @param handler ハンドラ - * @throws TraversalHandlerException ハンドラの処理が失敗した場合 - */ - public static void forEach(final File rootDir, final ClassHandler handler) throws TraversalHandlerException { - forEach(rootDir, null, handler); - } - - /** - * rootディレクトリ配下でrootパッケージ名配下を処理します。 - * - * @param rootDir ルートディレクトリ - * @param rootPackage ルートパッケージ - * @param handler ハンドラ - * @throws TraversalHandlerException ハンドラの処理が失敗した場合 - */ - public static void forEach(final File rootDir, final String rootPackage, final ClassHandler handler) - throws TraversalHandlerException { - final File packageDir = getPackageDir(rootDir, rootPackage); - if (packageDir.exists()) { - traverseFileSystem(packageDir, rootPackage, handler); - } - } - - /** - * 指定されたjarファイルを処理します。 - * - * @param jarFile Jarファイル - * @param handler ハンドラ - * @throws TraversalHandlerException ハンドラの処理が失敗した場合 - */ - public static void forEach(final JarFile jarFile, final ClassHandler handler) throws TraversalHandlerException { - final boolean hasWarExtension = jarFile.getName().endsWith(WAR_FILE_EXTENSION); - final Enumeration<JarEntry> enumeration = jarFile.entries(); - while (enumeration.hasMoreElements()) { - final JarEntry entry = enumeration.nextElement(); - final String entryName = entry.getName().replace('\\', '/'); - if (entryName.endsWith(CLASS_SUFFIX)) { - final int startPos = - hasWarExtension && entryName.startsWith(WEB_INF_CLASSES_PATH) ? WEB_INF_CLASSES_PATH.length() - : 0; - final String className = - entryName.substring(startPos, entryName.length() - CLASS_SUFFIX.length()).replace('/', '.'); - final int pos = className.lastIndexOf('.'); - final String packageName = (pos == -1) ? null : className.substring(0, pos); - final String shortClassName = (pos == -1) ? className : className.substring(pos + 1); - handler.processClass(packageName, shortClassName); - } - } - } - - private static File getPackageDir(final File rootDir, final String rootPackage) { - File packageDir = rootDir; - if (rootPackage != null) { - final String[] names = rootPackage.split("\\."); - for (String name : names) { - packageDir = new File(packageDir, name); - } - } - return packageDir; - } - - private static void traverseFileSystem(final File dir, final String packageName, final ClassHandler handler) - throws TraversalHandlerException { - final File[] files = dir.listFiles(); - for (int i = 0; i < files.length; ++i) { - final File file = files[i]; - final String fileName = file.getName(); - if (file.isDirectory()) { - traverseFileSystem(file, ClassUtil.concatName(packageName, fileName), handler); - } else if (fileName.endsWith(".class")) { - final String shortClassName = fileName.substring(0, fileName.length() - CLASS_SUFFIX.length()); - handler.processClass(packageName, shortClassName); - } - } - } - - private ClassTraversal() { - throw new JiemamyError("不到達ポイント"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.File; +import java.util.Enumeration; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +import org.jiemamy.exception.JiemamyError; + +/** + * クラスを横断して処理するためのハンドらクラス。 + * + * @author j5ik2o + */ +public class ClassTraversal { + + /** + * クラスを横断して処理するためのハンドラインターフェイス。 + * + */ + public interface ClassHandler { + + /** + * クラスを処理する。 + * + * @param packageName パッケージ名 + * @param shortClassName クラス名 + * @throws TraversalHandlerException ハンドラの処理が失敗した場合 + */ + void processClass(String packageName, String shortClassName) throws TraversalHandlerException; + } + + + private static final String CLASS_SUFFIX = ".class"; + + private static final String WAR_FILE_EXTENSION = ".war"; + + private static final String WEB_INF_CLASSES_PATH = "WEB-INF/classes/"; + + + /** + * rootディレクトリ配下を処理します。 + * + * @param rootDir ルートディレクトリ + * @param handler ハンドラ + * @throws TraversalHandlerException ハンドラの処理が失敗した場合 + */ + public static void forEach(final File rootDir, final ClassHandler handler) throws TraversalHandlerException { + forEach(rootDir, null, handler); + } + + /** + * rootディレクトリ配下でrootパッケージ名配下を処理します。 + * + * @param rootDir ルートディレクトリ + * @param rootPackage ルートパッケージ + * @param handler ハンドラ + * @throws TraversalHandlerException ハンドラの処理が失敗した場合 + */ + public static void forEach(final File rootDir, final String rootPackage, final ClassHandler handler) + throws TraversalHandlerException { + final File packageDir = getPackageDir(rootDir, rootPackage); + if (packageDir.exists()) { + traverseFileSystem(packageDir, rootPackage, handler); + } + } + + /** + * 指定されたjarファイルを処理します。 + * + * @param jarFile Jarファイル + * @param handler ハンドラ + * @throws TraversalHandlerException ハンドラの処理が失敗した場合 + */ + public static void forEach(final JarFile jarFile, final ClassHandler handler) throws TraversalHandlerException { + final boolean hasWarExtension = jarFile.getName().endsWith(WAR_FILE_EXTENSION); + final Enumeration<JarEntry> enumeration = jarFile.entries(); + while (enumeration.hasMoreElements()) { + final JarEntry entry = enumeration.nextElement(); + final String entryName = entry.getName().replace('\\', '/'); + if (entryName.endsWith(CLASS_SUFFIX)) { + final int startPos = + hasWarExtension && entryName.startsWith(WEB_INF_CLASSES_PATH) ? WEB_INF_CLASSES_PATH.length() + : 0; + final String className = + entryName.substring(startPos, entryName.length() - CLASS_SUFFIX.length()).replace('/', '.'); + final int pos = className.lastIndexOf('.'); + final String packageName = (pos == -1) ? null : className.substring(0, pos); + final String shortClassName = (pos == -1) ? className : className.substring(pos + 1); + handler.processClass(packageName, shortClassName); + } + } + } + + private static File getPackageDir(final File rootDir, final String rootPackage) { + File packageDir = rootDir; + if (rootPackage != null) { + final String[] names = rootPackage.split("\\."); + for (String name : names) { + packageDir = new File(packageDir, name); + } + } + return packageDir; + } + + private static void traverseFileSystem(final File dir, final String packageName, final ClassHandler handler) + throws TraversalHandlerException { + final File[] files = dir.listFiles(); + for (int i = 0; i < files.length; ++i) { + final File file = files[i]; + final String fileName = file.getName(); + if (file.isDirectory()) { + traverseFileSystem(file, ClassUtil.concatName(packageName, fileName), handler); + } else if (fileName.endsWith(".class")) { + final String shortClassName = fileName.substring(0, fileName.length() - CLASS_SUFFIX.length()); + handler.processClass(packageName, shortClassName); + } + } + } + + private ClassTraversal() { + throw new JiemamyError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassTraversal.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,449 +1,449 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -import javassist.ClassPool; -import javassist.CtClass; -import javassist.CtField; -import javassist.NotFoundException; - -import org.apache.commons.lang.StringUtils; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link Class}用のユーティリティクラスです。 - * - * @author j5ik2o - * - */ -public class ClassUtil { - - private static Map<Class<?>, Class<?>> wrapperToPrimitiveMap = new HashMap<Class<?>, Class<?>>(); - - private static Map<Class<?>, Class<?>> primitiveToWrapperMap = new HashMap<Class<?>, Class<?>>(); - - private static Map<String, Class<?>> primitiveClsssNameMap = new HashMap<String, Class<?>>(); - - static { - wrapperToPrimitiveMap.put(Character.class, Character.TYPE); - wrapperToPrimitiveMap.put(Byte.class, Byte.TYPE); - wrapperToPrimitiveMap.put(Short.class, Short.TYPE); - wrapperToPrimitiveMap.put(Integer.class, Integer.TYPE); - wrapperToPrimitiveMap.put(Long.class, Long.TYPE); - wrapperToPrimitiveMap.put(Double.class, Double.TYPE); - wrapperToPrimitiveMap.put(Float.class, Float.TYPE); - wrapperToPrimitiveMap.put(Boolean.class, Boolean.TYPE); - - primitiveToWrapperMap.put(Character.TYPE, Character.class); - primitiveToWrapperMap.put(Byte.TYPE, Byte.class); - primitiveToWrapperMap.put(Short.TYPE, Short.class); - primitiveToWrapperMap.put(Integer.TYPE, Integer.class); - primitiveToWrapperMap.put(Long.TYPE, Long.class); - primitiveToWrapperMap.put(Double.TYPE, Double.class); - primitiveToWrapperMap.put(Float.TYPE, Float.class); - primitiveToWrapperMap.put(Boolean.TYPE, Boolean.class); - - primitiveClsssNameMap.put(Character.TYPE.getName(), Character.TYPE); - primitiveClsssNameMap.put(Byte.TYPE.getName(), Byte.TYPE); - primitiveClsssNameMap.put(Short.TYPE.getName(), Short.TYPE); - primitiveClsssNameMap.put(Integer.TYPE.getName(), Integer.TYPE); - primitiveClsssNameMap.put(Long.TYPE.getName(), Long.TYPE); - primitiveClsssNameMap.put(Double.TYPE.getName(), Double.TYPE); - primitiveClsssNameMap.put(Float.TYPE.getName(), Float.TYPE); - primitiveClsssNameMap.put(Boolean.TYPE.getName(), Boolean.TYPE); - } - - - /** - * クラス名の要素を結合する。 - * - * @param s1 パッケージ名 - * @param s2 パッケージ名もしくはクラス名 - * @return 結合された名前 - */ - public static String concatName(String s1, String s2) { - if (StringUtils.isEmpty(s1) && StringUtils.isEmpty(s2)) { - return null; - } - if (!StringUtils.isEmpty(s1) && StringUtils.isEmpty(s2)) { - return s1; - } - if (StringUtils.isEmpty(s1) && !StringUtils.isEmpty(s2)) { - return s2; - } - return s1 + '.' + s2; - } - - /** - * プリミティブクラスの場合は、ラッパークラスに変換する。 - * - * @param className クラス名 - * @return {@link Class} - * @throws ClassNotFoundException クラスが見つからなかった場合 - * @see #forName(String) - */ - public static Class<?> convertClass(String className) throws ClassNotFoundException { - Class<?> clazz = primitiveClsssNameMap.get(className); - if (clazz != null) { - return clazz; - } - return forName(className); - } - - /** - * {@link Class}を取得する。 - * - * @param className クラス名 - * @return {@link Class} - * @throws ClassNotFoundException クラスが見つからなかった場合 - * @see Class#forName(String) - */ - public static Class<?> forName(String className) throws ClassNotFoundException { - ClassLoader loader = Thread.currentThread().getContextClassLoader(); - return Class.forName(className, true, loader); - } - - /** - * {@link Constructor}を返します。 - * - * @param clazz クラス - * @param argTypes 引数 - * @return {@link Constructor} - * @throws NoSuchMethodException メソッドが存在しない場合 - * @throws SecurityException セキュリティ違反が発生した場合 - * @see Class#getConstructor(Class[]) - */ - public static Constructor<?> getConstructor(Class<?> clazz, Class<?>[] argTypes) throws SecurityException, - NoSuchMethodException { - return clazz.getConstructor(argTypes); - } - - /** - * そのクラスに宣言されている {@link Constructor}を取得する。 - * - * @param clazz クラス - * @param argTypes 引数 - * @return {@link Constructor} - * @throws NoSuchMethodException メソッドが存在しない場合 - * @throws SecurityException セキュリティ違反が発生した場合 - * @see Class#getDeclaredConstructor(Class[]) - */ - public static Constructor<?> getDeclaredConstructor(Class<?> clazz, Class<?>[] argTypes) throws SecurityException, - NoSuchMethodException { - return clazz.getDeclaredConstructor(argTypes); - } - - /** - * そのクラスに宣言されている {@link Field}を取得する。 - * - * @param clazz クラス - * @param fieldName フィールド名 - * @return {@link Field} - * @throws NoSuchFieldException フィールドが見つからなかった場合 - * @see Class#getDeclaredField(String) - */ - public static Field getDeclaredField(Class<?> clazz, String fieldName) throws NoSuchFieldException { - return clazz.getDeclaredField(fieldName); - } - - /** - * このクラスに定義された{@link Field フィールド}をクラスファイルに定義された順番で取得する。 - * - * @param clazz 対象のクラス - * @return このクラスに定義されたフィールドの配列 - * @throws NotFoundException {@link CtClass}が見つからなかった場合 - * @throws NoSuchFieldException フィールドが見つからなかった場合 - */ - public static Field[] getDeclaredFields(final Class<?> clazz) throws NotFoundException, NoSuchFieldException { - try { - final ClassPool pool = ClassPoolUtil.getClassPool(clazz); - final CtClass ctClass = ClassPoolUtil.toCtClass(pool, clazz); - final CtField[] ctFields = ctClass.getDeclaredFields(); - final int size = ctFields.length; - final Field[] fields = new Field[size]; - for (int i = 0; i < size; ++i) { - fields[i] = ClassUtil.getDeclaredField(clazz, ctFields[i].getName()); - } - return fields; - } finally { - ClassPoolUtil.dispose(); - } - } - - /** - * そのクラスに宣言されている {@link Method}を取得する。 - * - * @param clazz クラス - * @param methodName メソッド名 - * @param argTypes 引数 - * @return {@link Method} メソッド - * @throws NoSuchMethodException メソッドが存在しない場合 - * @throws SecurityException セキュリティ違反が発生した場合 - * @see Class#getDeclaredMethod(String, Class[]) - */ - public static Method getDeclaredMethod(Class<?> clazz, String methodName, Class<?>[] argTypes) - throws SecurityException, NoSuchMethodException { - return clazz.getDeclaredMethod(methodName, argTypes); - } - - /** - * {@link Field}を取得する。 - * - * @param clazz クラス - * @param fieldName フィールド名 - * @return {@link Field} - * @throws NoSuchFieldException フィールドが見つからなかった場合 - * @see Class#getField(String) - */ - public static Field getField(Class<?> clazz, String fieldName) throws NoSuchFieldException { - return clazz.getField(fieldName); - } - - /** - * {@link Field}を取得する。ただし、例外はスローしない。 - * - * @param clazz クラス - * @param fieldName フィールド名 - * @return {@link Field} - * @see Class#getField(String) - */ - public static Field getFieldNoException(Class<?> clazz, String fieldName) { - try { - return clazz.getField(fieldName); - } catch (SecurityException e) { - return null; - } catch (NoSuchFieldException e) { - return null; - } - } - - /** - * {@link Method}を取得する。 - * - * @param clazz クラス - * @param methodName メソッド名 - * @param argTypes 引数 - * @return {@link Method} - * @throws NoSuchMethodException メソッドがみつからなかった場合 - * @throws SecurityException セキュリティ違反が発生した場合 - * @see Class#getMethod(String, Class[]) - */ - public static Method getMethod(Class<?> clazz, String methodName, Class<?>[] argTypes) throws SecurityException, - NoSuchMethodException { - return clazz.getMethod(methodName, argTypes); - } - - /** - * パッケージ名を取得する。 - * - * @param clazz クラス - * @return パッケージ名 - */ - public static String getPackageName(Class<?> clazz) { - String fqcn = clazz.getName(); - int pos = fqcn.lastIndexOf('.'); - if (pos > 0) { - return fqcn.substring(0, pos); - } - return null; - } - - /** - * ラッパークラスをプリミティブクラスに変換する。 - * - * @param clazz クラス - * @return プリミティブクラス - */ - public static Class<?> getPrimitiveClass(Class<?> clazz) { - return wrapperToPrimitiveMap.get(clazz); - } - - /** - * ラッパークラスならプリミティブクラスに、 そうでなければそのままクラスを取得する。 - * - * @param clazz クラス - * @return {@link Class} - */ - public static Class<?> getPrimitiveClassIfWrapper(Class<?> clazz) { - Class<?> ret = getPrimitiveClass(clazz); - if (ret != null) { - return ret; - } - return clazz; - } - - /** - * クラス名をリソースパスに変換する。 - * - * @param clazz クラス - * @return リソースパス - * @see #getResourcePath(String) - */ - public static String getResourcePath(Class<?> clazz) { - return getResourcePath(clazz.getName()); - } - - /** - * クラス名をリソースパスに変換する。 - * - * @param className クラス名 - * @return リソースパス - */ - public static String getResourcePath(String className) { - return StringUtils.replace(className, ".", "/") + ".class"; - } - - /** - * FQCNからパッケージ名を除いた名前を取得する。 - * - * @param clazz クラス - * @return FQCNからパッケージ名を除いた名前 - * @see #getShortClassName(String) - */ - public static String getShortClassName(Class<?> clazz) { - return getShortClassName(clazz.getName()); - } - - /** - * FQCNからパッケージ名を除いた名前を取得する。 - * - * @param className クラス名 - * @return FQCNからパッケージ名を除いた名前 - */ - public static String getShortClassName(String className) { - int i = className.lastIndexOf('.'); - if (i > 0) { - return className.substring(i + 1); - } - return className; - } - - /** - * 配列の場合は要素のクラス名、それ以外はクラス名そのものを返します。 - * - * @param clazz クラス - * @return クラス名 - */ - public static String getSimpleClassName(final Class<?> clazz) { - if (clazz.isArray()) { - return getSimpleClassName(clazz.getComponentType()) + "[]"; - } - return clazz.getName(); - } - - /** - * プリミティブクラスをラッパークラスに変換する。 - * - * @param clazz クラス - * @return {@link Class} - */ - public static Class<?> getWrapperClass(Class<?> clazz) { - return primitiveToWrapperMap.get(clazz); - } - - /** - * プリミティブの場合はラッパークラス、そうでない場合はもとのクラスを取得する。 - * - * @param clazz クラス - * @return {@link Class} - */ - public static Class<?> getWrapperClassIfPrimitive(Class<?> clazz) { - Class<?> ret = getWrapperClass(clazz); - if (ret != null) { - return ret; - } - return clazz; - } - - /** - * 代入可能かどうかをチェックする。 - * - * @param toClass 代入先のクラス - * @param fromClass 代入元のクラス - * @return 代入可能かどうか - * @see Class#isAssignableFrom(Class) - */ - public static boolean isAssignableFrom(Class<?> toClass, Class<?> fromClass) { - if (toClass == Object.class && !fromClass.isPrimitive()) { - return true; - } - if (toClass.isPrimitive()) { - fromClass = getPrimitiveClassIfWrapper(fromClass); - } - return toClass.isAssignableFrom(fromClass); - } - - /** - * 新しいインスタンスを作成する。 - * - * @param clazz クラス - * @return 新しいインスタンス - * @throws InstantiationException この Class が abstract クラス、インタフェース、配列クラス、プリミティブ型、 - * または void を表す場合、クラスが null コンストラクタを保持しない場合、あるいはインスタンスの生成がほかの理由で失敗した場合 - * @throws IllegalAccessException コンストラクタにアクセスできない場合 - * @see Class#newInstance() - */ - public static Object newInstance(Class<?> clazz) throws InstantiationException, IllegalAccessException { - return clazz.newInstance(); - } - - /** - * 新しいインスタンスを作成する。 - * - * @param className クラス名 - * @return 新しいインスタンス - * @throws InstantiationException この Class が abstract クラス、インタフェース、配列クラス、プリミティブ型、 - * または void を表す場合、クラスが null コンストラクタを保持しない場合、あるいはインスタンスの生成がほかの理由で失敗した場合 - * @throws IllegalAccessException コンストラクタにアクセスできない場合 - * @throws ClassNotFoundException クラスが見つからなかった場合 - * @see #newInstance(Class) - */ - public static Object newInstance(String className) throws InstantiationException, IllegalAccessException, - ClassNotFoundException { - return newInstance(forName(className)); - } - - /** - * FQCNをパッケージ名とFQCNからパッケージ名を除いた名前に分割する。 - * - * @param className クラス名 - * @return パッケージ名とFQCNからパッケージ名を除いた名前 - */ - public static String[] splitPackageAndShortClassName(String className) { - String[] ret = new String[2]; - int i = className.lastIndexOf('.'); - if (i > 0) { - ret[0] = className.substring(0, i); - ret[1] = className.substring(i + 1); - } else { - ret[1] = className; - } - return ret; - } - - private ClassUtil() { - throw new JiemamyError("不到達ポイント"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import javassist.ClassPool; +import javassist.CtClass; +import javassist.CtField; +import javassist.NotFoundException; + +import org.apache.commons.lang.StringUtils; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link Class}用のユーティリティクラスです。 + * + * @author j5ik2o + * + */ +public class ClassUtil { + + private static Map<Class<?>, Class<?>> wrapperToPrimitiveMap = new HashMap<Class<?>, Class<?>>(); + + private static Map<Class<?>, Class<?>> primitiveToWrapperMap = new HashMap<Class<?>, Class<?>>(); + + private static Map<String, Class<?>> primitiveClsssNameMap = new HashMap<String, Class<?>>(); + + static { + wrapperToPrimitiveMap.put(Character.class, Character.TYPE); + wrapperToPrimitiveMap.put(Byte.class, Byte.TYPE); + wrapperToPrimitiveMap.put(Short.class, Short.TYPE); + wrapperToPrimitiveMap.put(Integer.class, Integer.TYPE); + wrapperToPrimitiveMap.put(Long.class, Long.TYPE); + wrapperToPrimitiveMap.put(Double.class, Double.TYPE); + wrapperToPrimitiveMap.put(Float.class, Float.TYPE); + wrapperToPrimitiveMap.put(Boolean.class, Boolean.TYPE); + + primitiveToWrapperMap.put(Character.TYPE, Character.class); + primitiveToWrapperMap.put(Byte.TYPE, Byte.class); + primitiveToWrapperMap.put(Short.TYPE, Short.class); + primitiveToWrapperMap.put(Integer.TYPE, Integer.class); + primitiveToWrapperMap.put(Long.TYPE, Long.class); + primitiveToWrapperMap.put(Double.TYPE, Double.class); + primitiveToWrapperMap.put(Float.TYPE, Float.class); + primitiveToWrapperMap.put(Boolean.TYPE, Boolean.class); + + primitiveClsssNameMap.put(Character.TYPE.getName(), Character.TYPE); + primitiveClsssNameMap.put(Byte.TYPE.getName(), Byte.TYPE); + primitiveClsssNameMap.put(Short.TYPE.getName(), Short.TYPE); + primitiveClsssNameMap.put(Integer.TYPE.getName(), Integer.TYPE); + primitiveClsssNameMap.put(Long.TYPE.getName(), Long.TYPE); + primitiveClsssNameMap.put(Double.TYPE.getName(), Double.TYPE); + primitiveClsssNameMap.put(Float.TYPE.getName(), Float.TYPE); + primitiveClsssNameMap.put(Boolean.TYPE.getName(), Boolean.TYPE); + } + + + /** + * クラス名の要素を結合する。 + * + * @param s1 パッケージ名 + * @param s2 パッケージ名もしくはクラス名 + * @return 結合された名前 + */ + public static String concatName(String s1, String s2) { + if (StringUtils.isEmpty(s1) && StringUtils.isEmpty(s2)) { + return null; + } + if (!StringUtils.isEmpty(s1) && StringUtils.isEmpty(s2)) { + return s1; + } + if (StringUtils.isEmpty(s1) && !StringUtils.isEmpty(s2)) { + return s2; + } + return s1 + '.' + s2; + } + + /** + * プリミティブクラスの場合は、ラッパークラスに変換する。 + * + * @param className クラス名 + * @return {@link Class} + * @throws ClassNotFoundException クラスが見つからなかった場合 + * @see #forName(String) + */ + public static Class<?> convertClass(String className) throws ClassNotFoundException { + Class<?> clazz = primitiveClsssNameMap.get(className); + if (clazz != null) { + return clazz; + } + return forName(className); + } + + /** + * {@link Class}を取得する。 + * + * @param className クラス名 + * @return {@link Class} + * @throws ClassNotFoundException クラスが見つからなかった場合 + * @see Class#forName(String) + */ + public static Class<?> forName(String className) throws ClassNotFoundException { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + return Class.forName(className, true, loader); + } + + /** + * {@link Constructor}を返します。 + * + * @param clazz クラス + * @param argTypes 引数 + * @return {@link Constructor} + * @throws NoSuchMethodException メソッドが存在しない場合 + * @throws SecurityException セキュリティ違反が発生した場合 + * @see Class#getConstructor(Class[]) + */ + public static Constructor<?> getConstructor(Class<?> clazz, Class<?>[] argTypes) throws SecurityException, + NoSuchMethodException { + return clazz.getConstructor(argTypes); + } + + /** + * そのクラスに宣言されている {@link Constructor}を取得する。 + * + * @param clazz クラス + * @param argTypes 引数 + * @return {@link Constructor} + * @throws NoSuchMethodException メソッドが存在しない場合 + * @throws SecurityException セキュリティ違反が発生した場合 + * @see Class#getDeclaredConstructor(Class[]) + */ + public static Constructor<?> getDeclaredConstructor(Class<?> clazz, Class<?>[] argTypes) throws SecurityException, + NoSuchMethodException { + return clazz.getDeclaredConstructor(argTypes); + } + + /** + * そのクラスに宣言されている {@link Field}を取得する。 + * + * @param clazz クラス + * @param fieldName フィールド名 + * @return {@link Field} + * @throws NoSuchFieldException フィールドが見つからなかった場合 + * @see Class#getDeclaredField(String) + */ + public static Field getDeclaredField(Class<?> clazz, String fieldName) throws NoSuchFieldException { + return clazz.getDeclaredField(fieldName); + } + + /** + * このクラスに定義された{@link Field フィールド}をクラスファイルに定義された順番で取得する。 + * + * @param clazz 対象のクラス + * @return このクラスに定義されたフィールドの配列 + * @throws NotFoundException {@link CtClass}が見つからなかった場合 + * @throws NoSuchFieldException フィールドが見つからなかった場合 + */ + public static Field[] getDeclaredFields(final Class<?> clazz) throws NotFoundException, NoSuchFieldException { + try { + final ClassPool pool = ClassPoolUtil.getClassPool(clazz); + final CtClass ctClass = ClassPoolUtil.toCtClass(pool, clazz); + final CtField[] ctFields = ctClass.getDeclaredFields(); + final int size = ctFields.length; + final Field[] fields = new Field[size]; + for (int i = 0; i < size; ++i) { + fields[i] = ClassUtil.getDeclaredField(clazz, ctFields[i].getName()); + } + return fields; + } finally { + ClassPoolUtil.dispose(); + } + } + + /** + * そのクラスに宣言されている {@link Method}を取得する。 + * + * @param clazz クラス + * @param methodName メソッド名 + * @param argTypes 引数 + * @return {@link Method} メソッド + * @throws NoSuchMethodException メソッドが存在しない場合 + * @throws SecurityException セキュリティ違反が発生した場合 + * @see Class#getDeclaredMethod(String, Class[]) + */ + public static Method getDeclaredMethod(Class<?> clazz, String methodName, Class<?>[] argTypes) + throws SecurityException, NoSuchMethodException { + return clazz.getDeclaredMethod(methodName, argTypes); + } + + /** + * {@link Field}を取得する。 + * + * @param clazz クラス + * @param fieldName フィールド名 + * @return {@link Field} + * @throws NoSuchFieldException フィールドが見つからなかった場合 + * @see Class#getField(String) + */ + public static Field getField(Class<?> clazz, String fieldName) throws NoSuchFieldException { + return clazz.getField(fieldName); + } + + /** + * {@link Field}を取得する。ただし、例外はスローしない。 + * + * @param clazz クラス + * @param fieldName フィールド名 + * @return {@link Field} + * @see Class#getField(String) + */ + public static Field getFieldNoException(Class<?> clazz, String fieldName) { + try { + return clazz.getField(fieldName); + } catch (SecurityException e) { + return null; + } catch (NoSuchFieldException e) { + return null; + } + } + + /** + * {@link Method}を取得する。 + * + * @param clazz クラス + * @param methodName メソッド名 + * @param argTypes 引数 + * @return {@link Method} + * @throws NoSuchMethodException メソッドがみつからなかった場合 + * @throws SecurityException セキュリティ違反が発生した場合 + * @see Class#getMethod(String, Class[]) + */ + public static Method getMethod(Class<?> clazz, String methodName, Class<?>[] argTypes) throws SecurityException, + NoSuchMethodException { + return clazz.getMethod(methodName, argTypes); + } + + /** + * パッケージ名を取得する。 + * + * @param clazz クラス + * @return パッケージ名 + */ + public static String getPackageName(Class<?> clazz) { + String fqcn = clazz.getName(); + int pos = fqcn.lastIndexOf('.'); + if (pos > 0) { + return fqcn.substring(0, pos); + } + return null; + } + + /** + * ラッパークラスをプリミティブクラスに変換する。 + * + * @param clazz クラス + * @return プリミティブクラス + */ + public static Class<?> getPrimitiveClass(Class<?> clazz) { + return wrapperToPrimitiveMap.get(clazz); + } + + /** + * ラッパークラスならプリミティブクラスに、 そうでなければそのままクラスを取得する。 + * + * @param clazz クラス + * @return {@link Class} + */ + public static Class<?> getPrimitiveClassIfWrapper(Class<?> clazz) { + Class<?> ret = getPrimitiveClass(clazz); + if (ret != null) { + return ret; + } + return clazz; + } + + /** + * クラス名をリソースパスに変換する。 + * + * @param clazz クラス + * @return リソースパス + * @see #getResourcePath(String) + */ + public static String getResourcePath(Class<?> clazz) { + return getResourcePath(clazz.getName()); + } + + /** + * クラス名をリソースパスに変換する。 + * + * @param className クラス名 + * @return リソースパス + */ + public static String getResourcePath(String className) { + return StringUtils.replace(className, ".", "/") + ".class"; + } + + /** + * FQCNからパッケージ名を除いた名前を取得する。 + * + * @param clazz クラス + * @return FQCNからパッケージ名を除いた名前 + * @see #getShortClassName(String) + */ + public static String getShortClassName(Class<?> clazz) { + return getShortClassName(clazz.getName()); + } + + /** + * FQCNからパッケージ名を除いた名前を取得する。 + * + * @param className クラス名 + * @return FQCNからパッケージ名を除いた名前 + */ + public static String getShortClassName(String className) { + int i = className.lastIndexOf('.'); + if (i > 0) { + return className.substring(i + 1); + } + return className; + } + + /** + * 配列の場合は要素のクラス名、それ以外はクラス名そのものを返します。 + * + * @param clazz クラス + * @return クラス名 + */ + public static String getSimpleClassName(final Class<?> clazz) { + if (clazz.isArray()) { + return getSimpleClassName(clazz.getComponentType()) + "[]"; + } + return clazz.getName(); + } + + /** + * プリミティブクラスをラッパークラスに変換する。 + * + * @param clazz クラス + * @return {@link Class} + */ + public static Class<?> getWrapperClass(Class<?> clazz) { + return primitiveToWrapperMap.get(clazz); + } + + /** + * プリミティブの場合はラッパークラス、そうでない場合はもとのクラスを取得する。 + * + * @param clazz クラス + * @return {@link Class} + */ + public static Class<?> getWrapperClassIfPrimitive(Class<?> clazz) { + Class<?> ret = getWrapperClass(clazz); + if (ret != null) { + return ret; + } + return clazz; + } + + /** + * 代入可能かどうかをチェックする。 + * + * @param toClass 代入先のクラス + * @param fromClass 代入元のクラス + * @return 代入可能かどうか + * @see Class#isAssignableFrom(Class) + */ + public static boolean isAssignableFrom(Class<?> toClass, Class<?> fromClass) { + if (toClass == Object.class && !fromClass.isPrimitive()) { + return true; + } + if (toClass.isPrimitive()) { + fromClass = getPrimitiveClassIfWrapper(fromClass); + } + return toClass.isAssignableFrom(fromClass); + } + + /** + * 新しいインスタンスを作成する。 + * + * @param clazz クラス + * @return 新しいインスタンス + * @throws InstantiationException この Class が abstract クラス、インタフェース、配列クラス、プリミティブ型、 + * または void を表す場合、クラスが null コンストラクタを保持しない場合、あるいはインスタンスの生成がほかの理由で失敗した場合 + * @throws IllegalAccessException コンストラクタにアクセスできない場合 + * @see Class#newInstance() + */ + public static Object newInstance(Class<?> clazz) throws InstantiationException, IllegalAccessException { + return clazz.newInstance(); + } + + /** + * 新しいインスタンスを作成する。 + * + * @param className クラス名 + * @return 新しいインスタンス + * @throws InstantiationException この Class が abstract クラス、インタフェース、配列クラス、プリミティブ型、 + * または void を表す場合、クラスが null コンストラクタを保持しない場合、あるいはインスタンスの生成がほかの理由で失敗した場合 + * @throws IllegalAccessException コンストラクタにアクセスできない場合 + * @throws ClassNotFoundException クラスが見つからなかった場合 + * @see #newInstance(Class) + */ + public static Object newInstance(String className) throws InstantiationException, IllegalAccessException, + ClassNotFoundException { + return newInstance(forName(className)); + } + + /** + * FQCNをパッケージ名とFQCNからパッケージ名を除いた名前に分割する。 + * + * @param className クラス名 + * @return パッケージ名とFQCNからパッケージ名を除いた名前 + */ + public static String[] splitPackageAndShortClassName(String className) { + String[] ret = new String[2]; + int i = className.lastIndexOf('.'); + if (i > 0) { + ret[0] = className.substring(0, i); + ret[1] = className.substring(i + 1); + } else { + ret[1] = className; + } + return ret; + } + + private ClassUtil() { + throw new JiemamyError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ClassUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/CollectionsUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/CollectionsUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/CollectionsUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,998 +1,998 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.IdentityHashMap; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.Map; -import java.util.PriorityQueue; -import java.util.SortedMap; -import java.util.SortedSet; -import java.util.Stack; -import java.util.TreeMap; -import java.util.TreeSet; -import java.util.Vector; -import java.util.WeakHashMap; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.CopyOnWriteArraySet; -import java.util.concurrent.DelayQueue; -import java.util.concurrent.Delayed; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.PriorityBlockingQueue; - -import org.jiemamy.exception.JiemamyError; - -/** - * Genericsや可変長を活用するコレクションのためのユーティリティ。 - * - * @author j5ik2o - */ -public class CollectionsUtil { - - /** - * {@link ArrayBlockingQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link ArrayBlockingQueue}の要素型 - * @param capacity キューの容量 - * @return {@link ArrayBlockingQueue}の新しいインスタンス - * @see ArrayBlockingQueue#ArrayBlockingQueue(int) - */ - public static <E>ArrayBlockingQueue<E> newArrayBlockingQueue(final int capacity) { - return new ArrayBlockingQueue<E>(capacity); - } - - /** - * {@link ArrayBlockingQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link ArrayBlockingQueue}の要素型 - * @param capacity キューの容量 - * @param fair {@code true}の場合、挿入または削除時にブロックされたスレッドに対するキューアクセス - * @return {@link ArrayBlockingQueue}の新しいインスタンス - * @see ArrayBlockingQueue#ArrayBlockingQueue(int, boolean) - */ - public static <E>ArrayBlockingQueue<E> newArrayBlockingQueue(final int capacity, final boolean fair) { - return new ArrayBlockingQueue<E>(capacity, fair); - } - - /** - * {@link ArrayBlockingQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link ArrayBlockingQueue}の要素型 - * @param capacity キューの容量 - * @param fair {@code true}の場合、挿入または削除時にブロックされたスレッドに対するキューアクセス - * @param c 最初に含む要素のコレクション - * @return {@link ArrayBlockingQueue}の新しいインスタンス - * @see ArrayBlockingQueue#ArrayBlockingQueue(int, boolean, Collection) - */ - public static <E>ArrayBlockingQueue<E> newArrayBlockingQueue(final int capacity, final boolean fair, - final Collection<? extends E> c) { - return new ArrayBlockingQueue<E>(capacity, fair, c); - } - - /** - * {@link ArrayList}の新しいインスタンスを作成する。 - * - * @param <E> {@link ArrayList}の要素型 - * @return {@link ArrayList}の新しいインスタンス - * @see ArrayList#ArrayList() - */ - public static <E>ArrayList<E> newArrayList() { - return new ArrayList<E>(); - } - - /** - * {@link ArrayList}の新しいインスタンスを作成する。 - * - * @param <E> {@link ArrayList}の要素型 - * @param c 要素がリストに配置されるコレクション - * @return {@link ArrayList}の新しいインスタンス - * @see ArrayList#ArrayList(Collection) - */ - public static <E>ArrayList<E> newArrayList(final Collection<? extends E> c) { - return new ArrayList<E>(c); - } - - /** - * {@link ArrayList}の新しいインスタンスを作成する。 - * - * @param <E> {@link ArrayList}の要素型 - * @param initialCapacity リストの初期容量 - * @return {@link ArrayList}の新しいインスタンス - * @see ArrayList#ArrayList(int) - */ - public static <E>ArrayList<E> newArrayList(final int initialCapacity) { - return new ArrayList<E>(initialCapacity); - } - - /** - * {@link ConcurrentHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link ConcurrentHashMap}のキーの型 - * @param <V> {@link ConcurrentHashMap}の値の型 - * @return {@link ConcurrentHashMap}の新しいインスタンス - * @see ConcurrentHashMap#ConcurrentHashMap() - */ - public static <K, V>ConcurrentHashMap<K, V> newConcurrentHashMap() { - return new ConcurrentHashMap<K, V>(); - } - - /** - * {@link ConcurrentHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link ConcurrentHashMap}のキーの型 - * @param <V> {@link ConcurrentHashMap}の値の型 - * @param initialCapacity 初期容量 - * @return {@link ConcurrentHashMap}の新しいインスタンス - * @see ConcurrentHashMap#ConcurrentHashMap(int) - */ - public static <K, V>ConcurrentHashMap<K, V> newConcurrentHashMap(final int initialCapacity) { - return new ConcurrentHashMap<K, V>(initialCapacity); - } - - /** - * {@link ConcurrentHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link ConcurrentHashMap}のキーの型 - * @param <V> {@link ConcurrentHashMap}の値の型 - * @param initialCapacity 初期容量 - * @param loadFactor サイズ変更の制御に使用される負荷係数のしきい値 - * @param concurrencyLevel 同時更新を行うスレッドの推定数 - * @return {@link ConcurrentHashMap}の新しいインスタンス - * @see ConcurrentHashMap#ConcurrentHashMap(int, float, int) - */ - public static <K, V>ConcurrentHashMap<K, V> newConcurrentHashMap(final int initialCapacity, final float loadFactor, - final int concurrencyLevel) { - return new ConcurrentHashMap<K, V>(initialCapacity, loadFactor, concurrencyLevel); - } - - /** - * {@link ConcurrentHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link ConcurrentHashMap}のキーの型 - * @param <V> {@link ConcurrentHashMap}の値の型 - * @param m 作成されるマップに配置されるマップ - * @return {@link ConcurrentHashMap}の新しいインスタンス - * @see ConcurrentHashMap#ConcurrentHashMap(Map) - */ - public static <K, V>ConcurrentHashMap<K, V> newConcurrentHashMap(final Map<? extends K, ? extends V> m) { - return new ConcurrentHashMap<K, V>(m); - } - - /** - * {@link ConcurrentLinkedQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link ConcurrentLinkedQueue}の要素型 - * @return {@link ConcurrentLinkedQueue}の新しいインスタンス - * @see ConcurrentLinkedQueue#ConcurrentLinkedQueue() - */ - public static <E>ConcurrentLinkedQueue<E> newConcurrentLinkedQueue() { - return new ConcurrentLinkedQueue<E>(); - } - - /** - * {@link ConcurrentLinkedQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link ConcurrentLinkedQueue}の要素型 - * @param c 最初に含む要素のコレクション - * @return {@link ConcurrentLinkedQueue}の新しいインスタンス - * @see ConcurrentLinkedQueue#ConcurrentLinkedQueue(Collection) - */ - public static <E>ConcurrentLinkedQueue<E> newConcurrentLinkedQueue(final Collection<? extends E> c) { - return new ConcurrentLinkedQueue<E>(c); - } - - /** - * {@link CopyOnWriteArrayList}の新しいインスタンスを作成する。 - * - * @param <E> {@link CopyOnWriteArrayList}の要素型 - * @return {@link CopyOnWriteArrayList}の新しいインスタンス - * @see CopyOnWriteArrayList#CopyOnWriteArrayList() - */ - public static <E>CopyOnWriteArrayList<E> newCopyOnWriteArrayList() { - return new CopyOnWriteArrayList<E>(); - } - - /** - * {@link CopyOnWriteArrayList}の新しいインスタンスを作成する。 - * - * @param <E> {@link CopyOnWriteArrayList}の要素型 - * @param c 最初に保持していた要素のコレクション - * @return {@link CopyOnWriteArrayList}の新しいインスタンス - * @see CopyOnWriteArrayList#CopyOnWriteArrayList(Collection) - */ - public static <E>CopyOnWriteArrayList<E> newCopyOnWriteArrayList(final Collection<? extends E> c) { - return new CopyOnWriteArrayList<E>(c); - } - - /** - * {@link CopyOnWriteArrayList}の新しいインスタンスを作成する。 - * - * @param <E> {@link CopyOnWriteArrayList}の要素型 - * @param toCopyIn 配列 (この配列のコピーは内部配列として使用される) - * @return {@link CopyOnWriteArrayList}の新しいインスタンス - * @see CopyOnWriteArrayList#CopyOnWriteArrayList(Object[]) - */ - public static <E>CopyOnWriteArrayList<E> newCopyOnWriteArrayList(final E[] toCopyIn) { - return new CopyOnWriteArrayList<E>(toCopyIn); - } - - /** - * {@link CopyOnWriteArraySet}の新しいインスタンスを作成する。 - * - * @param <E> {@link CopyOnWriteArraySet}の要素型 - * @return {@link CopyOnWriteArraySet}の新しいインスタンス - * @see CopyOnWriteArraySet#CopyOnWriteArraySet() - */ - public static <E>CopyOnWriteArraySet<E> newCopyOnWriteArraySet() { - return new CopyOnWriteArraySet<E>(); - } - - /** - * {@link CopyOnWriteArraySet}の新しいインスタンスを作成する。 - * - * @param <E> {@link CopyOnWriteArraySet}の要素型 - * @param c コレクション - * @return {@link CopyOnWriteArraySet}の新しいインスタンス - * @see CopyOnWriteArraySet#CopyOnWriteArraySet(Collection) - */ - public static <E>CopyOnWriteArraySet<E> newCopyOnWriteArraySet(final Collection<? extends E> c) { - return new CopyOnWriteArraySet<E>(c); - } - - /** - * {@link DelayQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link CopyOnWriteArraySet}の要素型 - * @return {@link DelayQueue}の新しいインスタンス - * @see DelayQueue#DelayQueue() - */ - public static <E extends Delayed>DelayQueue<E> newDelayQueue() { - return new DelayQueue<E>(); - } - - /** - * {@link DelayQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link CopyOnWriteArraySet}の要素型 - * @param c コレクション - * @return {@link DelayQueue}の新しいインスタンス - * @see DelayQueue#DelayQueue(Collection) - */ - public static <E extends Delayed>DelayQueue<E> newDelayQueue(final Collection<? extends E> c) { - return new DelayQueue<E>(c); - } - - /** - * {@link HashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link HashMap}のキーの型 - * @param <V> {@link HashMap}の値の型 - * @return {@link HashMap}の新しいインスタンス - * @see HashMap#HashMap() - */ - public static <K, V>HashMap<K, V> newHashMap() { - return new HashMap<K, V>(); - } - - /** - * {@link HashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link HashMap}のキーの型 - * @param <V> {@link HashMap}の値の型 - * @param initialCapacity 初期容量 - * @return {@link HashMap}の新しいインスタンス - * @see HashMap#HashMap(int) - */ - public static <K, V>HashMap<K, V> newHashMap(final int initialCapacity) { - return new HashMap<K, V>(initialCapacity); - } - - /** - * {@link HashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link HashMap}のキーの型 - * @param <V> {@link HashMap}の値の型 - * @param initialCapacity 初期容量 - * @param loadFactor サイズ変更の制御に使用される負荷係数のしきい値 - * @return {@link HashMap}の新しいインスタンス - * @see HashMap#HashMap(int, float) - */ - public static <K, V>HashMap<K, V> newHashMap(final int initialCapacity, final float loadFactor) { - return new HashMap<K, V>(initialCapacity, loadFactor); - } - - /** - * {@link HashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link HashMap}のキーの型 - * @param <V> {@link HashMap}の値の型 - * @param m 作成されるマップに配置されるマップ - * @return {@link HashMap}の新しいインスタンス - * @see HashMap#HashMap(int, float) - */ - public static <K, V>HashMap<K, V> newHashMap(final Map<? extends K, ? extends V> m) { - return new HashMap<K, V>(m); - } - - /** - * {@link HashSet}の新しいインスタンスを作成する。 - * - * @param <E> {@link HashSet}の要素型 - * @return {@link HashSet}の新しいインスタンス - * @see HashSet#HashSet() - */ - public static <E>HashSet<E> newHashSet() { - return new HashSet<E>(); - } - - /** - * {@link HashSet}の新しいインスタンスを作成する。 - * - * @param <E> {@link HashSet}の要素型 - * @param c 要素がセットに配置されるコレクション - * @return {@link HashSet}の新しいインスタンス - * @see HashSet#HashSet() - */ - public static <E>HashSet<E> newHashSet(final Collection<? extends E> c) { - return new HashSet<E>(c); - } - - /** - * {@link HashSet}の新しいインスタンスを作成する。 - * - * @param <E> {@link HashSet}の要素型 - * @param initialCapacity 初期容量 - * @return {@link HashSet}の新しいインスタンス - * @see HashSet#HashSet() - */ - public static <E>HashSet<E> newHashSet(final int initialCapacity) { - return new HashSet<E>(initialCapacity); - } - - /** - * {@link HashSet}の新しいインスタンスを作成する。 - * - * @param <E> {@link HashSet}の要素型 - * @param initialCapacity 初期容量 - * @param loadFactor 負荷係数 - * @return {@link HashSet}の新しいインスタンス - * @see HashSet#HashSet() - */ - public static <E>HashSet<E> newHashSet(final int initialCapacity, final float loadFactor) { - return new HashSet<E>(initialCapacity, loadFactor); - } - - /** - * {@link Hashtable}の新しいインスタンスを作成する。 - * - * @param <K> {@link Hashtable}のキーの型 - * @param <V> {@link Hashtable}の値の型 - * @return {@link Hashtable}の新しいインスタンス - * @see Hashtable#Hashtable() - */ - public static <K, V>Hashtable<K, V> newHashtable() { - return new Hashtable<K, V>(); - } - - /** - * {@link Hashtable}の新しいインスタンスを作成する。 - * - * @param <K> {@link Hashtable}のキーの型 - * @param <V> {@link Hashtable}の値の型 - * @param initialCapacity ハッシュテーブルの初期容量 - * @return {@link Hashtable}の新しいインスタンス - * @see Hashtable#Hashtable(int) - */ - public static <K, V>Hashtable<K, V> newHashtable(final int initialCapacity) { - return new Hashtable<K, V>(initialCapacity); - } - - /** - * {@link Hashtable}の新しいインスタンスを作成する。 - * - * @param <K> {@link Hashtable}のキーの型 - * @param <V> {@link Hashtable}の値の型 - * @param initialCapacity ハッシュテーブルの初期容量 - * @param loadFactor ハッシュテーブルの負荷係数 - * @return {@link Hashtable}の新しいインスタンス - * @see Hashtable#Hashtable(int, float) - */ - public static <K, V>Hashtable<K, V> newHashtable(final int initialCapacity, final float loadFactor) { - return new Hashtable<K, V>(initialCapacity, loadFactor); - } - - /** - * {@link Hashtable}の新しいインスタンスを作成する。 - * - * @param <K> {@link Hashtable}のキーの型 - * @param <V> {@link Hashtable}の値の型 - * @param m 作成されるマップに配置されるマップ - * @return {@link Hashtable}の新しいインスタンス - * @see Hashtable#Hashtable(Map) - */ - public static <K, V>Hashtable<K, V> newHashtable(final Map<? extends K, ? extends V> m) { - return new Hashtable<K, V>(m); - } - - /** - * {@link IdentityHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link IdentityHashMap}のキーの型 - * @param <V> {@link IdentityHashMap}の値の型 - * @return {@link IdentityHashMap}の新しいインスタンス - * @see IdentityHashMap#IdentityHashMap() - */ - public static <K, V>IdentityHashMap<K, V> newIdentityHashMap() { - return new IdentityHashMap<K, V>(); - } - - /** - * {@link IdentityHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link IdentityHashMap}のキーの型 - * @param <V> {@link IdentityHashMap}の値の型 - * @param expectedMaxSize マップの予想最大サイズ - * @return {@link IdentityHashMap}の新しいインスタンス - * @see IdentityHashMap#IdentityHashMap(int) - */ - public static <K, V>IdentityHashMap<K, V> newIdentityHashMap(final int expectedMaxSize) { - return new IdentityHashMap<K, V>(expectedMaxSize); - } - - /** - * {@link IdentityHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link IdentityHashMap}のキーの型 - * @param <V> {@link IdentityHashMap}の値の型 - * @param m 作成されるマップに配置されるマップ - * @return {@link IdentityHashMap}の新しいインスタンス - * @see IdentityHashMap#IdentityHashMap(Map) - */ - public static <K, V>IdentityHashMap<K, V> newIdentityHashMap(final Map<? extends K, ? extends V> m) { - return new IdentityHashMap<K, V>(m); - } - - /** - * {@link LinkedBlockingQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link LinkedBlockingQueue}の要素型 - * @return {@link LinkedBlockingQueue}の新しいインスタンス - * @see LinkedBlockingQueue#LinkedBlockingQueue() - */ - public static <E>LinkedBlockingQueue<E> newLinkedBlockingQueue() { - return new LinkedBlockingQueue<E>(); - } - - /** - * {@link LinkedBlockingQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link LinkedBlockingQueue}の要素型 - * @param c 最初に含む要素のコレクション - * @return {@link LinkedBlockingQueue}の新しいインスタンス - * @see LinkedBlockingQueue#LinkedBlockingQueue(Collection) - */ - public static <E>LinkedBlockingQueue<E> newLinkedBlockingQueue(final Collection<? extends E> c) { - return new LinkedBlockingQueue<E>(c); - } - - /** - * {@link LinkedBlockingQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link LinkedBlockingQueue}の要素型 - * @param initialCapacity このキューの容量 - * @return {@link LinkedBlockingQueue}の新しいインスタンス - * @see LinkedBlockingQueue#LinkedBlockingQueue(int) - */ - public static <E>LinkedBlockingQueue<E> newLinkedBlockingQueue(final int initialCapacity) { - return new LinkedBlockingQueue<E>(initialCapacity); - } - - /** - * {@link LinkedHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link LinkedHashMap}のキーの型 - * @param <V> {@link LinkedHashMap}の値の型 - * @return {@link LinkedHashMap}の新しいインスタンス - * @see LinkedHashMap#LinkedHashMap() - */ - public static <K, V>LinkedHashMap<K, V> newLinkedHashMap() { - return new LinkedHashMap<K, V>(); - } - - /** - * {@link LinkedHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link LinkedHashMap}のキーの型 - * @param <V> {@link LinkedHashMap}の値の型 - * @param initialCapacity 初期容量 - * @return {@link LinkedHashMap}の新しいインスタンス - * @see LinkedHashMap#LinkedHashMap(int) - */ - public static <K, V>LinkedHashMap<K, V> newLinkedHashMap(final int initialCapacity) { - return new LinkedHashMap<K, V>(initialCapacity); - } - - /** - * {@link LinkedHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link LinkedHashMap}のキーの型 - * @param <V> {@link LinkedHashMap}の値の型 - * @param initialCapacity 初期容量 - * @param loadFactor 負荷係数 - * @return {@link LinkedHashMap}の新しいインスタンス - * @see LinkedHashMap#LinkedHashMap(int, float) - */ - public static <K, V>LinkedHashMap<K, V> newLinkedHashMap(final int initialCapacity, final float loadFactor) { - return new LinkedHashMap<K, V>(initialCapacity, loadFactor); - } - - /** - * {@link LinkedHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link LinkedHashMap}のキーの型 - * @param <V> {@link LinkedHashMap}の値の型 - * @param m 作成されるマップに配置されるマップ - * @return {@link LinkedHashMap}の新しいインスタンス - * @see LinkedHashMap#LinkedHashMap(Map) - */ - public static <K, V>LinkedHashMap<K, V> newLinkedHashMap(final Map<? extends K, ? extends V> m) { - return new LinkedHashMap<K, V>(m); - } - - /** - * {@link LinkedHashSet}の新しいインスタンスを作成する。 - * - * @param <E> {@link LinkedHashSet}の要素型 - * @return {@link LinkedHashSet}の新しいインスタンス - * @see LinkedHashSet#LinkedHashSet() - */ - public static <E>LinkedHashSet<E> newLinkedHashSet() { - return new LinkedHashSet<E>(); - } - - /** - * {@link LinkedHashSet}の新しいインスタンスを作成する。 - * - * @param <E> {@link LinkedHashSet}の要素型 - * @param c 要素がセットに配置されるコレクション - * @return {@link LinkedHashSet}の新しいインスタンス - * @see LinkedHashSet#LinkedHashSet(Collection) - */ - public static <E>LinkedHashSet<E> newLinkedHashSet(final Collection<? extends E> c) { - return new LinkedHashSet<E>(c); - } - - /** - * {@link LinkedHashSet}の新しいインスタンスを作成する。 - * - * @param <E> {@link LinkedHashSet}の要素型 - * @param initialCapacity 初期容量 - * @return {@link LinkedHashSet}の新しいインスタンス - * @see LinkedHashSet#LinkedHashSet(int) - */ - public static <E>LinkedHashSet<E> newLinkedHashSet(final int initialCapacity) { - return new LinkedHashSet<E>(initialCapacity); - } - - /** - * {@link LinkedHashSet}の新しいインスタンスを作成する。 - * - * @param <E> {@link LinkedHashSet}の要素型 - * @param initialCapacity 初期容量 - * @param loadFactor 負荷係数 - * @return {@link LinkedHashSet}の新しいインスタンス - * @see LinkedHashSet#LinkedHashSet(int, float) - */ - public static <E>LinkedHashSet<E> newLinkedHashSet(final int initialCapacity, final float loadFactor) { - return new LinkedHashSet<E>(initialCapacity, loadFactor); - } - - /** - * {@link LinkedList}の新しいインスタンスを作成する。 - * - * @param <E> {@link LinkedList}の要素型 - * @return {@link LinkedList}の新しいインスタンス - * @see LinkedList#LinkedList() - */ - public static <E>LinkedList<E> newLinkedList() { - return new LinkedList<E>(); - } - - /** - * {@link LinkedList}の新しいインスタンスを作成する。 - * - * @param <E> {@link LinkedList}の要素型 - * @param c 要素がリストに配置されるコレクション - * @return {@link LinkedList}の新しいインスタンス - * @see LinkedList#LinkedList(Collection) - */ - public static <E>LinkedList<E> newLinkedList(final Collection<? extends E> c) { - return new LinkedList<E>(c); - } - - /** - * {@link PriorityBlockingQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link PriorityBlockingQueue}の要素型 - * @return {@link PriorityBlockingQueue}の新しいインスタンス - * @see PriorityBlockingQueue#PriorityBlockingQueue() - */ - public static <E>PriorityBlockingQueue<E> newPriorityBlockingQueue() { - return new PriorityBlockingQueue<E>(); - } - - /** - * {@link PriorityBlockingQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link PriorityBlockingQueue}の要素型 - * @param c 最初に含む要素のコレクション - * @return {@link PriorityBlockingQueue}の新しいインスタンス - * @see PriorityBlockingQueue#PriorityBlockingQueue(Collection) - */ - public static <E>PriorityBlockingQueue<E> newPriorityBlockingQueue(final Collection<? extends E> c) { - return new PriorityBlockingQueue<E>(c); - } - - /** - * {@link PriorityBlockingQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link PriorityBlockingQueue}の要素型 - * @param initialCapacity この優先度キューの初期容量 - * @return {@link PriorityBlockingQueue}の新しいインスタンス - * @see PriorityBlockingQueue#PriorityBlockingQueue(int) - */ - public static <E>PriorityBlockingQueue<E> newPriorityBlockingQueue(final int initialCapacity) { - return new PriorityBlockingQueue<E>(initialCapacity); - } - - /** - * {@link PriorityBlockingQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link PriorityBlockingQueue}の要素型 - * @param initialCapacity この優先度キューの初期容量 - * @param comparator この優先度キューの順序付けに使用するコンパレータ - * @return {@link PriorityBlockingQueue}の新しいインスタンス - * @see PriorityBlockingQueue#PriorityBlockingQueue(int, Comparator) - */ - public static <E>PriorityBlockingQueue<E> newPriorityBlockingQueue(final int initialCapacity, - final Comparator<? super E> comparator) { - return new PriorityBlockingQueue<E>(initialCapacity, comparator); - } - - /** - * {@link PriorityQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link PriorityQueue}の要素型 - * @return {@link PriorityQueue}の新しいインスタンス - * @see PriorityQueue#PriorityQueue() - */ - public static <E>PriorityQueue<E> newPriorityQueue() { - return new PriorityQueue<E>(); - } - - /** - * {@link PriorityQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link PriorityQueue}の要素型 - * @param c 要素が優先度キューに配置されるコレクション - * @return {@link PriorityQueue}の新しいインスタンス - * @see PriorityQueue#PriorityQueue(Collection) - */ - public static <E>PriorityQueue<E> newPriorityQueue(final Collection<? extends E> c) { - return new PriorityQueue<E>(c); - } - - /** - * {@link PriorityQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link PriorityQueue}の要素型 - * @param initialCapacity この優先度キューの初期容量 - * @return {@link PriorityQueue}の新しいインスタンス - * @see PriorityQueue#PriorityQueue(int) - */ - public static <E>PriorityQueue<E> newPriorityQueue(final int initialCapacity) { - return new PriorityQueue<E>(initialCapacity); - } - - /** - * {@link PriorityQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link PriorityQueue}の要素型 - * @param initialCapacity この優先度キューの初期容量 - * @param comparator この優先度キューの順序付けに使用するコンパレータ - * @return {@link PriorityQueue}の新しいインスタンス - * @see PriorityQueue#PriorityQueue(int, Comparator) - */ - public static <E>PriorityQueue<E> newPriorityQueue(final int initialCapacity, final Comparator<? super E> comparator) { - return new PriorityQueue<E>(initialCapacity, comparator); - } - - /** - * {@link PriorityQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link PriorityQueue}の要素型 - * @param c 要素が優先度キューに配置されるコレクション - * @return {@link PriorityQueue}の新しいインスタンス - * @see PriorityQueue#PriorityQueue(PriorityQueue) - */ - public static <E>PriorityQueue<E> newPriorityQueue(final PriorityQueue<? extends E> c) { - return new PriorityQueue<E>(c); - } - - /** - * {@link PriorityQueue}の新しいインスタンスを作成する。 - * - * @param <E> {@link PriorityQueue}の要素型 - * @param c 要素が優先度キューに配置されるコレクション - * @return {@link PriorityQueue}の新しいインスタンス - * @see PriorityQueue#PriorityQueue(SortedSet) - */ - public static <E>PriorityQueue<E> newPriorityQueue(final SortedSet<? extends E> c) { - return new PriorityQueue<E>(c); - } - - /** - * {@link Stack}の新しいインスタンスを作成する。 - * - * @param <E> {@link Stack}の要素型 - * @return {@link Stack}の新しいインスタンス - * @see Stack#Stack() - */ - public static <E>Stack<E> newStack() { - return new Stack<E>(); - } - - /** - * {@link TreeMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link TreeMap}のキーの型 - * @param <V> {@link TreeMap}の値の型 - * @return {@link TreeMap}の新しいインスタンス - * @see TreeMap#TreeMap() - */ - public static <K, V>TreeMap<K, V> newTreeMap() { - return new TreeMap<K, V>(); - } - - /** - * {@link TreeMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link TreeMap}のキーの型 - * @param <V> {@link TreeMap}の値の型 - * @param c {@link Comparator} - * @return {@link TreeMap}の新しいインスタンス - * @see TreeMap#TreeMap() - */ - public static <K, V>TreeMap<K, V> newTreeMap(final Comparator<? super K> c) { - return new TreeMap<K, V>(c); - } - - /** - * {@link TreeMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link TreeMap}のキーの型 - * @param <V> {@link TreeMap}の値の型 - * @param m 作成されるマップに配置されるマップ - * @return {@link TreeMap}の新しいインスタンス - * @see TreeMap#TreeMap(Map) - */ - public static <K, V>TreeMap<K, V> newTreeMap(final Map<? extends K, ? extends V> m) { - return new TreeMap<K, V>(m); - } - - /** - * {@link TreeMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link TreeMap}のキーの型 - * @param <V> {@link TreeMap}の値の型 - * @param m 作成されるマップに配置されるマップ - * @return {@link TreeMap}の新しいインスタンス - * @see TreeMap#TreeMap(SortedMap) - */ - public static <K, V>TreeMap<K, V> newTreeMap(final SortedMap<K, ? extends V> m) { - return new TreeMap<K, V>(m); - } - - /** - * {@link TreeSet}の新しいインスタンスを作成する。 - * - * @param <E> {@link TreeSet}の要素型 - * @return {@link TreeSet}の新しいインスタンス - * @see TreeSet#TreeSet() - */ - public static <E>TreeSet<E> newTreeSet() { - return new TreeSet<E>(); - } - - /** - * {@link TreeSet}の新しいインスタンスを作成する。 - * - * @param <E> {@link TreeSet}の要素型 - * @param c 要素がセットに配置されるコレクション - * @return {@link TreeSet}の新しいインスタンス - * @see TreeSet#TreeSet(Collection) - */ - public static <E>TreeSet<E> newTreeSet(final Collection<? extends E> c) { - return new TreeSet<E>(c); - } - - /** - * {@link TreeSet}の新しいインスタンスを作成する。 - * - * @param <E> {@link TreeSet}の要素型 - * @param c このセットをソートするために使用されるコンパレータ - * @return {@link TreeSet}の新しいインスタンス - * @see TreeSet#TreeSet(Comparator) - */ - public static <E>TreeSet<E> newTreeSet(final Comparator<? super E> c) { - return new TreeSet<E>(c); - } - - /** - * {@link TreeSet}の新しいインスタンスを作成する。 - * - * @param <E> {@link TreeSet}の要素型 - * @param s 要素がセットに配置されるコレクション - * @return {@link TreeSet}の新しいインスタンス - * @see TreeSet#TreeSet(SortedSet) - */ - public static <E>TreeSet<E> newTreeSet(final SortedSet<? extends E> s) { - return new TreeSet<E>(s); - } - - /** - * {@link Vector}の新しいインスタンスを作成する。 - * - * @param <E> {@link Vector}の要素型 - * @return {@link Vector}の新しいインスタンス - * @see Vector#Vector() - */ - public static <E>Vector<E> newVector() { - return new Vector<E>(); - } - - /** - * {@link Vector}の新しいインスタンスを作成する。 - * - * @param <E> {@link Vector}の要素型 - * @param c 要素がセットに配置されるコレクション - * @return {@link Vector}の新しいインスタンス - * @see Vector#Vector(Collection) - */ - public static <E>Vector<E> newVector(final Collection<? extends E> c) { - return new Vector<E>(c); - } - - /** - * {@link Vector}の新しいインスタンスを作成する。 - * - * @param <E> {@link Vector}の要素型 - * @param initialCapacity {@link Vector}の初期容量 - * @return {@link Vector}の新しいインスタンス - * @see Vector#Vector(int) - */ - public static <E>Vector<E> newVector(final int initialCapacity) { - return new Vector<E>(initialCapacity); - } - - /** - * {@link Vector}の新しいインスタンスを作成する。 - * - * @param <E> {@link Vector}の要素型 - * @param initialCapacity {@link Vector}の初期容量 - * @param capacityIncrement {@link Vector}があふれたときに増加される容量 - * @return {@link Vector}の新しいインスタンス - * @see Vector#Vector(int, int) - */ - public static <E>Vector<E> newVector(final int initialCapacity, final int capacityIncrement) { - return new Vector<E>(initialCapacity, capacityIncrement); - } - - /** - * {@link WeakHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link WeakHashMap}のキーの型 - * @param <V> {@link WeakHashMap}の値の型 - * @return {@link WeakHashMap}の新しいインスタンス - * @see WeakHashMap#WeakHashMap() - */ - public static <K, V>WeakHashMap<K, V> newWeakHashMap() { - return new WeakHashMap<K, V>(); - } - - /** - * {@link WeakHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link WeakHashMap}のキーの型 - * @param <V> {@link WeakHashMap}の値の型 - * @param initialCapacity 初期容量 - * @return {@link WeakHashMap}の新しいインスタンス - * @see WeakHashMap#WeakHashMap(int) - */ - public static <K, V>WeakHashMap<K, V> newWeakHashMap(final int initialCapacity) { - return new WeakHashMap<K, V>(initialCapacity); - } - - /** - * {@link WeakHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link WeakHashMap}のキーの型 - * @param <V> {@link WeakHashMap}の値の型 - * @param initialCapacity 初期容量 - * @param loadFactor サイズ変更の制御に使用される負荷係数のしきい値 - * @return {@link WeakHashMap}の新しいインスタンス - * @see WeakHashMap#WeakHashMap(int, float) - */ - public static <K, V>WeakHashMap<K, V> newWeakHashMap(final int initialCapacity, final float loadFactor) { - return new WeakHashMap<K, V>(initialCapacity, loadFactor); - } - - /** - * {@link WeakHashMap}の新しいインスタンスを作成する。 - * - * @param <K> {@link WeakHashMap}のキーの型 - * @param <V> {@link WeakHashMap}の値の型 - * @param m 作成されるマップに配置されるマップ - * @return {@link WeakHashMap}の新しいインスタンス - * @see WeakHashMap#WeakHashMap(Map) - */ - public static <K, V>WeakHashMap<K, V> newWeakHashMap(final Map<? extends K, ? extends V> m) { - return new WeakHashMap<K, V>(m); - } - - /** - * マップが指定されたキーを含んでいない場合は、キーを指定された値に関連付けます。 - * <p> - * マップがすでに指定されたキーを含んでいる場合は、 キーに関連づけられている値を返します。 マップは変更されず、 指定された値は使われません。 - * マップがまだ指定されたキーを含んでいない場合は、 指定された値を値を返します。 マップは変更され、指定されたキーと指定された値が関連づけられます。 - * いずれの場合も、返される値はマップがその時点でキーと関連づけている値です。 - * </p> - * - * @param <K> {@link HashMap}のキーの型 - * @param <V> {@link HashMap}の値の型 - * @param map マップ - * @param key 指定される値が関連付けられるキー - * @param value 指定されるキーに関連付けられる値 - * @return 指定されたキーと関連付けられていた以前の値または、キーに関連付けられる値 - * @see ConcurrentHashMap#putIfAbsent(Object, Object) - */ - public static <K, V>V putIfAbsent(final ConcurrentMap<K, V> map, final K key, final V value) { - V exists = map.putIfAbsent(key, value); - if (exists != null) { - return exists; - } - return value; - } - - private CollectionsUtil() { - throw new JiemamyError("不到達ポイント"); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.IdentityHashMap; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.Map; +import java.util.PriorityQueue; +import java.util.SortedMap; +import java.util.SortedSet; +import java.util.Stack; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.Vector; +import java.util.WeakHashMap; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.concurrent.DelayQueue; +import java.util.concurrent.Delayed; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.PriorityBlockingQueue; + +import org.jiemamy.exception.JiemamyError; + +/** + * Genericsや可変長を活用するコレクションのためのユーティリティ。 + * + * @author j5ik2o + */ +public class CollectionsUtil { + + /** + * {@link ArrayBlockingQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link ArrayBlockingQueue}の要素型 + * @param capacity キューの容量 + * @return {@link ArrayBlockingQueue}の新しいインスタンス + * @see ArrayBlockingQueue#ArrayBlockingQueue(int) + */ + public static <E>ArrayBlockingQueue<E> newArrayBlockingQueue(final int capacity) { + return new ArrayBlockingQueue<E>(capacity); + } + + /** + * {@link ArrayBlockingQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link ArrayBlockingQueue}の要素型 + * @param capacity キューの容量 + * @param fair {@code true}の場合、挿入または削除時にブロックされたスレッドに対するキューアクセス + * @return {@link ArrayBlockingQueue}の新しいインスタンス + * @see ArrayBlockingQueue#ArrayBlockingQueue(int, boolean) + */ + public static <E>ArrayBlockingQueue<E> newArrayBlockingQueue(final int capacity, final boolean fair) { + return new ArrayBlockingQueue<E>(capacity, fair); + } + + /** + * {@link ArrayBlockingQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link ArrayBlockingQueue}の要素型 + * @param capacity キューの容量 + * @param fair {@code true}の場合、挿入または削除時にブロックされたスレッドに対するキューアクセス + * @param c 最初に含む要素のコレクション + * @return {@link ArrayBlockingQueue}の新しいインスタンス + * @see ArrayBlockingQueue#ArrayBlockingQueue(int, boolean, Collection) + */ + public static <E>ArrayBlockingQueue<E> newArrayBlockingQueue(final int capacity, final boolean fair, + final Collection<? extends E> c) { + return new ArrayBlockingQueue<E>(capacity, fair, c); + } + + /** + * {@link ArrayList}の新しいインスタンスを作成する。 + * + * @param <E> {@link ArrayList}の要素型 + * @return {@link ArrayList}の新しいインスタンス + * @see ArrayList#ArrayList() + */ + public static <E>ArrayList<E> newArrayList() { + return new ArrayList<E>(); + } + + /** + * {@link ArrayList}の新しいインスタンスを作成する。 + * + * @param <E> {@link ArrayList}の要素型 + * @param c 要素がリストに配置されるコレクション + * @return {@link ArrayList}の新しいインスタンス + * @see ArrayList#ArrayList(Collection) + */ + public static <E>ArrayList<E> newArrayList(final Collection<? extends E> c) { + return new ArrayList<E>(c); + } + + /** + * {@link ArrayList}の新しいインスタンスを作成する。 + * + * @param <E> {@link ArrayList}の要素型 + * @param initialCapacity リストの初期容量 + * @return {@link ArrayList}の新しいインスタンス + * @see ArrayList#ArrayList(int) + */ + public static <E>ArrayList<E> newArrayList(final int initialCapacity) { + return new ArrayList<E>(initialCapacity); + } + + /** + * {@link ConcurrentHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link ConcurrentHashMap}のキーの型 + * @param <V> {@link ConcurrentHashMap}の値の型 + * @return {@link ConcurrentHashMap}の新しいインスタンス + * @see ConcurrentHashMap#ConcurrentHashMap() + */ + public static <K, V>ConcurrentHashMap<K, V> newConcurrentHashMap() { + return new ConcurrentHashMap<K, V>(); + } + + /** + * {@link ConcurrentHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link ConcurrentHashMap}のキーの型 + * @param <V> {@link ConcurrentHashMap}の値の型 + * @param initialCapacity 初期容量 + * @return {@link ConcurrentHashMap}の新しいインスタンス + * @see ConcurrentHashMap#ConcurrentHashMap(int) + */ + public static <K, V>ConcurrentHashMap<K, V> newConcurrentHashMap(final int initialCapacity) { + return new ConcurrentHashMap<K, V>(initialCapacity); + } + + /** + * {@link ConcurrentHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link ConcurrentHashMap}のキーの型 + * @param <V> {@link ConcurrentHashMap}の値の型 + * @param initialCapacity 初期容量 + * @param loadFactor サイズ変更の制御に使用される負荷係数のしきい値 + * @param concurrencyLevel 同時更新を行うスレッドの推定数 + * @return {@link ConcurrentHashMap}の新しいインスタンス + * @see ConcurrentHashMap#ConcurrentHashMap(int, float, int) + */ + public static <K, V>ConcurrentHashMap<K, V> newConcurrentHashMap(final int initialCapacity, final float loadFactor, + final int concurrencyLevel) { + return new ConcurrentHashMap<K, V>(initialCapacity, loadFactor, concurrencyLevel); + } + + /** + * {@link ConcurrentHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link ConcurrentHashMap}のキーの型 + * @param <V> {@link ConcurrentHashMap}の値の型 + * @param m 作成されるマップに配置されるマップ + * @return {@link ConcurrentHashMap}の新しいインスタンス + * @see ConcurrentHashMap#ConcurrentHashMap(Map) + */ + public static <K, V>ConcurrentHashMap<K, V> newConcurrentHashMap(final Map<? extends K, ? extends V> m) { + return new ConcurrentHashMap<K, V>(m); + } + + /** + * {@link ConcurrentLinkedQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link ConcurrentLinkedQueue}の要素型 + * @return {@link ConcurrentLinkedQueue}の新しいインスタンス + * @see ConcurrentLinkedQueue#ConcurrentLinkedQueue() + */ + public static <E>ConcurrentLinkedQueue<E> newConcurrentLinkedQueue() { + return new ConcurrentLinkedQueue<E>(); + } + + /** + * {@link ConcurrentLinkedQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link ConcurrentLinkedQueue}の要素型 + * @param c 最初に含む要素のコレクション + * @return {@link ConcurrentLinkedQueue}の新しいインスタンス + * @see ConcurrentLinkedQueue#ConcurrentLinkedQueue(Collection) + */ + public static <E>ConcurrentLinkedQueue<E> newConcurrentLinkedQueue(final Collection<? extends E> c) { + return new ConcurrentLinkedQueue<E>(c); + } + + /** + * {@link CopyOnWriteArrayList}の新しいインスタンスを作成する。 + * + * @param <E> {@link CopyOnWriteArrayList}の要素型 + * @return {@link CopyOnWriteArrayList}の新しいインスタンス + * @see CopyOnWriteArrayList#CopyOnWriteArrayList() + */ + public static <E>CopyOnWriteArrayList<E> newCopyOnWriteArrayList() { + return new CopyOnWriteArrayList<E>(); + } + + /** + * {@link CopyOnWriteArrayList}の新しいインスタンスを作成する。 + * + * @param <E> {@link CopyOnWriteArrayList}の要素型 + * @param c 最初に保持していた要素のコレクション + * @return {@link CopyOnWriteArrayList}の新しいインスタンス + * @see CopyOnWriteArrayList#CopyOnWriteArrayList(Collection) + */ + public static <E>CopyOnWriteArrayList<E> newCopyOnWriteArrayList(final Collection<? extends E> c) { + return new CopyOnWriteArrayList<E>(c); + } + + /** + * {@link CopyOnWriteArrayList}の新しいインスタンスを作成する。 + * + * @param <E> {@link CopyOnWriteArrayList}の要素型 + * @param toCopyIn 配列 (この配列のコピーは内部配列として使用される) + * @return {@link CopyOnWriteArrayList}の新しいインスタンス + * @see CopyOnWriteArrayList#CopyOnWriteArrayList(Object[]) + */ + public static <E>CopyOnWriteArrayList<E> newCopyOnWriteArrayList(final E[] toCopyIn) { + return new CopyOnWriteArrayList<E>(toCopyIn); + } + + /** + * {@link CopyOnWriteArraySet}の新しいインスタンスを作成する。 + * + * @param <E> {@link CopyOnWriteArraySet}の要素型 + * @return {@link CopyOnWriteArraySet}の新しいインスタンス + * @see CopyOnWriteArraySet#CopyOnWriteArraySet() + */ + public static <E>CopyOnWriteArraySet<E> newCopyOnWriteArraySet() { + return new CopyOnWriteArraySet<E>(); + } + + /** + * {@link CopyOnWriteArraySet}の新しいインスタンスを作成する。 + * + * @param <E> {@link CopyOnWriteArraySet}の要素型 + * @param c コレクション + * @return {@link CopyOnWriteArraySet}の新しいインスタンス + * @see CopyOnWriteArraySet#CopyOnWriteArraySet(Collection) + */ + public static <E>CopyOnWriteArraySet<E> newCopyOnWriteArraySet(final Collection<? extends E> c) { + return new CopyOnWriteArraySet<E>(c); + } + + /** + * {@link DelayQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link CopyOnWriteArraySet}の要素型 + * @return {@link DelayQueue}の新しいインスタンス + * @see DelayQueue#DelayQueue() + */ + public static <E extends Delayed>DelayQueue<E> newDelayQueue() { + return new DelayQueue<E>(); + } + + /** + * {@link DelayQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link CopyOnWriteArraySet}の要素型 + * @param c コレクション + * @return {@link DelayQueue}の新しいインスタンス + * @see DelayQueue#DelayQueue(Collection) + */ + public static <E extends Delayed>DelayQueue<E> newDelayQueue(final Collection<? extends E> c) { + return new DelayQueue<E>(c); + } + + /** + * {@link HashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link HashMap}のキーの型 + * @param <V> {@link HashMap}の値の型 + * @return {@link HashMap}の新しいインスタンス + * @see HashMap#HashMap() + */ + public static <K, V>HashMap<K, V> newHashMap() { + return new HashMap<K, V>(); + } + + /** + * {@link HashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link HashMap}のキーの型 + * @param <V> {@link HashMap}の値の型 + * @param initialCapacity 初期容量 + * @return {@link HashMap}の新しいインスタンス + * @see HashMap#HashMap(int) + */ + public static <K, V>HashMap<K, V> newHashMap(final int initialCapacity) { + return new HashMap<K, V>(initialCapacity); + } + + /** + * {@link HashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link HashMap}のキーの型 + * @param <V> {@link HashMap}の値の型 + * @param initialCapacity 初期容量 + * @param loadFactor サイズ変更の制御に使用される負荷係数のしきい値 + * @return {@link HashMap}の新しいインスタンス + * @see HashMap#HashMap(int, float) + */ + public static <K, V>HashMap<K, V> newHashMap(final int initialCapacity, final float loadFactor) { + return new HashMap<K, V>(initialCapacity, loadFactor); + } + + /** + * {@link HashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link HashMap}のキーの型 + * @param <V> {@link HashMap}の値の型 + * @param m 作成されるマップに配置されるマップ + * @return {@link HashMap}の新しいインスタンス + * @see HashMap#HashMap(int, float) + */ + public static <K, V>HashMap<K, V> newHashMap(final Map<? extends K, ? extends V> m) { + return new HashMap<K, V>(m); + } + + /** + * {@link HashSet}の新しいインスタンスを作成する。 + * + * @param <E> {@link HashSet}の要素型 + * @return {@link HashSet}の新しいインスタンス + * @see HashSet#HashSet() + */ + public static <E>HashSet<E> newHashSet() { + return new HashSet<E>(); + } + + /** + * {@link HashSet}の新しいインスタンスを作成する。 + * + * @param <E> {@link HashSet}の要素型 + * @param c 要素がセットに配置されるコレクション + * @return {@link HashSet}の新しいインスタンス + * @see HashSet#HashSet() + */ + public static <E>HashSet<E> newHashSet(final Collection<? extends E> c) { + return new HashSet<E>(c); + } + + /** + * {@link HashSet}の新しいインスタンスを作成する。 + * + * @param <E> {@link HashSet}の要素型 + * @param initialCapacity 初期容量 + * @return {@link HashSet}の新しいインスタンス + * @see HashSet#HashSet() + */ + public static <E>HashSet<E> newHashSet(final int initialCapacity) { + return new HashSet<E>(initialCapacity); + } + + /** + * {@link HashSet}の新しいインスタンスを作成する。 + * + * @param <E> {@link HashSet}の要素型 + * @param initialCapacity 初期容量 + * @param loadFactor 負荷係数 + * @return {@link HashSet}の新しいインスタンス + * @see HashSet#HashSet() + */ + public static <E>HashSet<E> newHashSet(final int initialCapacity, final float loadFactor) { + return new HashSet<E>(initialCapacity, loadFactor); + } + + /** + * {@link Hashtable}の新しいインスタンスを作成する。 + * + * @param <K> {@link Hashtable}のキーの型 + * @param <V> {@link Hashtable}の値の型 + * @return {@link Hashtable}の新しいインスタンス + * @see Hashtable#Hashtable() + */ + public static <K, V>Hashtable<K, V> newHashtable() { + return new Hashtable<K, V>(); + } + + /** + * {@link Hashtable}の新しいインスタンスを作成する。 + * + * @param <K> {@link Hashtable}のキーの型 + * @param <V> {@link Hashtable}の値の型 + * @param initialCapacity ハッシュテーブルの初期容量 + * @return {@link Hashtable}の新しいインスタンス + * @see Hashtable#Hashtable(int) + */ + public static <K, V>Hashtable<K, V> newHashtable(final int initialCapacity) { + return new Hashtable<K, V>(initialCapacity); + } + + /** + * {@link Hashtable}の新しいインスタンスを作成する。 + * + * @param <K> {@link Hashtable}のキーの型 + * @param <V> {@link Hashtable}の値の型 + * @param initialCapacity ハッシュテーブルの初期容量 + * @param loadFactor ハッシュテーブルの負荷係数 + * @return {@link Hashtable}の新しいインスタンス + * @see Hashtable#Hashtable(int, float) + */ + public static <K, V>Hashtable<K, V> newHashtable(final int initialCapacity, final float loadFactor) { + return new Hashtable<K, V>(initialCapacity, loadFactor); + } + + /** + * {@link Hashtable}の新しいインスタンスを作成する。 + * + * @param <K> {@link Hashtable}のキーの型 + * @param <V> {@link Hashtable}の値の型 + * @param m 作成されるマップに配置されるマップ + * @return {@link Hashtable}の新しいインスタンス + * @see Hashtable#Hashtable(Map) + */ + public static <K, V>Hashtable<K, V> newHashtable(final Map<? extends K, ? extends V> m) { + return new Hashtable<K, V>(m); + } + + /** + * {@link IdentityHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link IdentityHashMap}のキーの型 + * @param <V> {@link IdentityHashMap}の値の型 + * @return {@link IdentityHashMap}の新しいインスタンス + * @see IdentityHashMap#IdentityHashMap() + */ + public static <K, V>IdentityHashMap<K, V> newIdentityHashMap() { + return new IdentityHashMap<K, V>(); + } + + /** + * {@link IdentityHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link IdentityHashMap}のキーの型 + * @param <V> {@link IdentityHashMap}の値の型 + * @param expectedMaxSize マップの予想最大サイズ + * @return {@link IdentityHashMap}の新しいインスタンス + * @see IdentityHashMap#IdentityHashMap(int) + */ + public static <K, V>IdentityHashMap<K, V> newIdentityHashMap(final int expectedMaxSize) { + return new IdentityHashMap<K, V>(expectedMaxSize); + } + + /** + * {@link IdentityHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link IdentityHashMap}のキーの型 + * @param <V> {@link IdentityHashMap}の値の型 + * @param m 作成されるマップに配置されるマップ + * @return {@link IdentityHashMap}の新しいインスタンス + * @see IdentityHashMap#IdentityHashMap(Map) + */ + public static <K, V>IdentityHashMap<K, V> newIdentityHashMap(final Map<? extends K, ? extends V> m) { + return new IdentityHashMap<K, V>(m); + } + + /** + * {@link LinkedBlockingQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link LinkedBlockingQueue}の要素型 + * @return {@link LinkedBlockingQueue}の新しいインスタンス + * @see LinkedBlockingQueue#LinkedBlockingQueue() + */ + public static <E>LinkedBlockingQueue<E> newLinkedBlockingQueue() { + return new LinkedBlockingQueue<E>(); + } + + /** + * {@link LinkedBlockingQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link LinkedBlockingQueue}の要素型 + * @param c 最初に含む要素のコレクション + * @return {@link LinkedBlockingQueue}の新しいインスタンス + * @see LinkedBlockingQueue#LinkedBlockingQueue(Collection) + */ + public static <E>LinkedBlockingQueue<E> newLinkedBlockingQueue(final Collection<? extends E> c) { + return new LinkedBlockingQueue<E>(c); + } + + /** + * {@link LinkedBlockingQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link LinkedBlockingQueue}の要素型 + * @param initialCapacity このキューの容量 + * @return {@link LinkedBlockingQueue}の新しいインスタンス + * @see LinkedBlockingQueue#LinkedBlockingQueue(int) + */ + public static <E>LinkedBlockingQueue<E> newLinkedBlockingQueue(final int initialCapacity) { + return new LinkedBlockingQueue<E>(initialCapacity); + } + + /** + * {@link LinkedHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link LinkedHashMap}のキーの型 + * @param <V> {@link LinkedHashMap}の値の型 + * @return {@link LinkedHashMap}の新しいインスタンス + * @see LinkedHashMap#LinkedHashMap() + */ + public static <K, V>LinkedHashMap<K, V> newLinkedHashMap() { + return new LinkedHashMap<K, V>(); + } + + /** + * {@link LinkedHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link LinkedHashMap}のキーの型 + * @param <V> {@link LinkedHashMap}の値の型 + * @param initialCapacity 初期容量 + * @return {@link LinkedHashMap}の新しいインスタンス + * @see LinkedHashMap#LinkedHashMap(int) + */ + public static <K, V>LinkedHashMap<K, V> newLinkedHashMap(final int initialCapacity) { + return new LinkedHashMap<K, V>(initialCapacity); + } + + /** + * {@link LinkedHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link LinkedHashMap}のキーの型 + * @param <V> {@link LinkedHashMap}の値の型 + * @param initialCapacity 初期容量 + * @param loadFactor 負荷係数 + * @return {@link LinkedHashMap}の新しいインスタンス + * @see LinkedHashMap#LinkedHashMap(int, float) + */ + public static <K, V>LinkedHashMap<K, V> newLinkedHashMap(final int initialCapacity, final float loadFactor) { + return new LinkedHashMap<K, V>(initialCapacity, loadFactor); + } + + /** + * {@link LinkedHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link LinkedHashMap}のキーの型 + * @param <V> {@link LinkedHashMap}の値の型 + * @param m 作成されるマップに配置されるマップ + * @return {@link LinkedHashMap}の新しいインスタンス + * @see LinkedHashMap#LinkedHashMap(Map) + */ + public static <K, V>LinkedHashMap<K, V> newLinkedHashMap(final Map<? extends K, ? extends V> m) { + return new LinkedHashMap<K, V>(m); + } + + /** + * {@link LinkedHashSet}の新しいインスタンスを作成する。 + * + * @param <E> {@link LinkedHashSet}の要素型 + * @return {@link LinkedHashSet}の新しいインスタンス + * @see LinkedHashSet#LinkedHashSet() + */ + public static <E>LinkedHashSet<E> newLinkedHashSet() { + return new LinkedHashSet<E>(); + } + + /** + * {@link LinkedHashSet}の新しいインスタンスを作成する。 + * + * @param <E> {@link LinkedHashSet}の要素型 + * @param c 要素がセットに配置されるコレクション + * @return {@link LinkedHashSet}の新しいインスタンス + * @see LinkedHashSet#LinkedHashSet(Collection) + */ + public static <E>LinkedHashSet<E> newLinkedHashSet(final Collection<? extends E> c) { + return new LinkedHashSet<E>(c); + } + + /** + * {@link LinkedHashSet}の新しいインスタンスを作成する。 + * + * @param <E> {@link LinkedHashSet}の要素型 + * @param initialCapacity 初期容量 + * @return {@link LinkedHashSet}の新しいインスタンス + * @see LinkedHashSet#LinkedHashSet(int) + */ + public static <E>LinkedHashSet<E> newLinkedHashSet(final int initialCapacity) { + return new LinkedHashSet<E>(initialCapacity); + } + + /** + * {@link LinkedHashSet}の新しいインスタンスを作成する。 + * + * @param <E> {@link LinkedHashSet}の要素型 + * @param initialCapacity 初期容量 + * @param loadFactor 負荷係数 + * @return {@link LinkedHashSet}の新しいインスタンス + * @see LinkedHashSet#LinkedHashSet(int, float) + */ + public static <E>LinkedHashSet<E> newLinkedHashSet(final int initialCapacity, final float loadFactor) { + return new LinkedHashSet<E>(initialCapacity, loadFactor); + } + + /** + * {@link LinkedList}の新しいインスタンスを作成する。 + * + * @param <E> {@link LinkedList}の要素型 + * @return {@link LinkedList}の新しいインスタンス + * @see LinkedList#LinkedList() + */ + public static <E>LinkedList<E> newLinkedList() { + return new LinkedList<E>(); + } + + /** + * {@link LinkedList}の新しいインスタンスを作成する。 + * + * @param <E> {@link LinkedList}の要素型 + * @param c 要素がリストに配置されるコレクション + * @return {@link LinkedList}の新しいインスタンス + * @see LinkedList#LinkedList(Collection) + */ + public static <E>LinkedList<E> newLinkedList(final Collection<? extends E> c) { + return new LinkedList<E>(c); + } + + /** + * {@link PriorityBlockingQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link PriorityBlockingQueue}の要素型 + * @return {@link PriorityBlockingQueue}の新しいインスタンス + * @see PriorityBlockingQueue#PriorityBlockingQueue() + */ + public static <E>PriorityBlockingQueue<E> newPriorityBlockingQueue() { + return new PriorityBlockingQueue<E>(); + } + + /** + * {@link PriorityBlockingQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link PriorityBlockingQueue}の要素型 + * @param c 最初に含む要素のコレクション + * @return {@link PriorityBlockingQueue}の新しいインスタンス + * @see PriorityBlockingQueue#PriorityBlockingQueue(Collection) + */ + public static <E>PriorityBlockingQueue<E> newPriorityBlockingQueue(final Collection<? extends E> c) { + return new PriorityBlockingQueue<E>(c); + } + + /** + * {@link PriorityBlockingQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link PriorityBlockingQueue}の要素型 + * @param initialCapacity この優先度キューの初期容量 + * @return {@link PriorityBlockingQueue}の新しいインスタンス + * @see PriorityBlockingQueue#PriorityBlockingQueue(int) + */ + public static <E>PriorityBlockingQueue<E> newPriorityBlockingQueue(final int initialCapacity) { + return new PriorityBlockingQueue<E>(initialCapacity); + } + + /** + * {@link PriorityBlockingQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link PriorityBlockingQueue}の要素型 + * @param initialCapacity この優先度キューの初期容量 + * @param comparator この優先度キューの順序付けに使用するコンパレータ + * @return {@link PriorityBlockingQueue}の新しいインスタンス + * @see PriorityBlockingQueue#PriorityBlockingQueue(int, Comparator) + */ + public static <E>PriorityBlockingQueue<E> newPriorityBlockingQueue(final int initialCapacity, + final Comparator<? super E> comparator) { + return new PriorityBlockingQueue<E>(initialCapacity, comparator); + } + + /** + * {@link PriorityQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link PriorityQueue}の要素型 + * @return {@link PriorityQueue}の新しいインスタンス + * @see PriorityQueue#PriorityQueue() + */ + public static <E>PriorityQueue<E> newPriorityQueue() { + return new PriorityQueue<E>(); + } + + /** + * {@link PriorityQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link PriorityQueue}の要素型 + * @param c 要素が優先度キューに配置されるコレクション + * @return {@link PriorityQueue}の新しいインスタンス + * @see PriorityQueue#PriorityQueue(Collection) + */ + public static <E>PriorityQueue<E> newPriorityQueue(final Collection<? extends E> c) { + return new PriorityQueue<E>(c); + } + + /** + * {@link PriorityQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link PriorityQueue}の要素型 + * @param initialCapacity この優先度キューの初期容量 + * @return {@link PriorityQueue}の新しいインスタンス + * @see PriorityQueue#PriorityQueue(int) + */ + public static <E>PriorityQueue<E> newPriorityQueue(final int initialCapacity) { + return new PriorityQueue<E>(initialCapacity); + } + + /** + * {@link PriorityQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link PriorityQueue}の要素型 + * @param initialCapacity この優先度キューの初期容量 + * @param comparator この優先度キューの順序付けに使用するコンパレータ + * @return {@link PriorityQueue}の新しいインスタンス + * @see PriorityQueue#PriorityQueue(int, Comparator) + */ + public static <E>PriorityQueue<E> newPriorityQueue(final int initialCapacity, final Comparator<? super E> comparator) { + return new PriorityQueue<E>(initialCapacity, comparator); + } + + /** + * {@link PriorityQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link PriorityQueue}の要素型 + * @param c 要素が優先度キューに配置されるコレクション + * @return {@link PriorityQueue}の新しいインスタンス + * @see PriorityQueue#PriorityQueue(PriorityQueue) + */ + public static <E>PriorityQueue<E> newPriorityQueue(final PriorityQueue<? extends E> c) { + return new PriorityQueue<E>(c); + } + + /** + * {@link PriorityQueue}の新しいインスタンスを作成する。 + * + * @param <E> {@link PriorityQueue}の要素型 + * @param c 要素が優先度キューに配置されるコレクション + * @return {@link PriorityQueue}の新しいインスタンス + * @see PriorityQueue#PriorityQueue(SortedSet) + */ + public static <E>PriorityQueue<E> newPriorityQueue(final SortedSet<? extends E> c) { + return new PriorityQueue<E>(c); + } + + /** + * {@link Stack}の新しいインスタンスを作成する。 + * + * @param <E> {@link Stack}の要素型 + * @return {@link Stack}の新しいインスタンス + * @see Stack#Stack() + */ + public static <E>Stack<E> newStack() { + return new Stack<E>(); + } + + /** + * {@link TreeMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link TreeMap}のキーの型 + * @param <V> {@link TreeMap}の値の型 + * @return {@link TreeMap}の新しいインスタンス + * @see TreeMap#TreeMap() + */ + public static <K, V>TreeMap<K, V> newTreeMap() { + return new TreeMap<K, V>(); + } + + /** + * {@link TreeMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link TreeMap}のキーの型 + * @param <V> {@link TreeMap}の値の型 + * @param c {@link Comparator} + * @return {@link TreeMap}の新しいインスタンス + * @see TreeMap#TreeMap() + */ + public static <K, V>TreeMap<K, V> newTreeMap(final Comparator<? super K> c) { + return new TreeMap<K, V>(c); + } + + /** + * {@link TreeMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link TreeMap}のキーの型 + * @param <V> {@link TreeMap}の値の型 + * @param m 作成されるマップに配置されるマップ + * @return {@link TreeMap}の新しいインスタンス + * @see TreeMap#TreeMap(Map) + */ + public static <K, V>TreeMap<K, V> newTreeMap(final Map<? extends K, ? extends V> m) { + return new TreeMap<K, V>(m); + } + + /** + * {@link TreeMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link TreeMap}のキーの型 + * @param <V> {@link TreeMap}の値の型 + * @param m 作成されるマップに配置されるマップ + * @return {@link TreeMap}の新しいインスタンス + * @see TreeMap#TreeMap(SortedMap) + */ + public static <K, V>TreeMap<K, V> newTreeMap(final SortedMap<K, ? extends V> m) { + return new TreeMap<K, V>(m); + } + + /** + * {@link TreeSet}の新しいインスタンスを作成する。 + * + * @param <E> {@link TreeSet}の要素型 + * @return {@link TreeSet}の新しいインスタンス + * @see TreeSet#TreeSet() + */ + public static <E>TreeSet<E> newTreeSet() { + return new TreeSet<E>(); + } + + /** + * {@link TreeSet}の新しいインスタンスを作成する。 + * + * @param <E> {@link TreeSet}の要素型 + * @param c 要素がセットに配置されるコレクション + * @return {@link TreeSet}の新しいインスタンス + * @see TreeSet#TreeSet(Collection) + */ + public static <E>TreeSet<E> newTreeSet(final Collection<? extends E> c) { + return new TreeSet<E>(c); + } + + /** + * {@link TreeSet}の新しいインスタンスを作成する。 + * + * @param <E> {@link TreeSet}の要素型 + * @param c このセットをソートするために使用されるコンパレータ + * @return {@link TreeSet}の新しいインスタンス + * @see TreeSet#TreeSet(Comparator) + */ + public static <E>TreeSet<E> newTreeSet(final Comparator<? super E> c) { + return new TreeSet<E>(c); + } + + /** + * {@link TreeSet}の新しいインスタンスを作成する。 + * + * @param <E> {@link TreeSet}の要素型 + * @param s 要素がセットに配置されるコレクション + * @return {@link TreeSet}の新しいインスタンス + * @see TreeSet#TreeSet(SortedSet) + */ + public static <E>TreeSet<E> newTreeSet(final SortedSet<? extends E> s) { + return new TreeSet<E>(s); + } + + /** + * {@link Vector}の新しいインスタンスを作成する。 + * + * @param <E> {@link Vector}の要素型 + * @return {@link Vector}の新しいインスタンス + * @see Vector#Vector() + */ + public static <E>Vector<E> newVector() { + return new Vector<E>(); + } + + /** + * {@link Vector}の新しいインスタンスを作成する。 + * + * @param <E> {@link Vector}の要素型 + * @param c 要素がセットに配置されるコレクション + * @return {@link Vector}の新しいインスタンス + * @see Vector#Vector(Collection) + */ + public static <E>Vector<E> newVector(final Collection<? extends E> c) { + return new Vector<E>(c); + } + + /** + * {@link Vector}の新しいインスタンスを作成する。 + * + * @param <E> {@link Vector}の要素型 + * @param initialCapacity {@link Vector}の初期容量 + * @return {@link Vector}の新しいインスタンス + * @see Vector#Vector(int) + */ + public static <E>Vector<E> newVector(final int initialCapacity) { + return new Vector<E>(initialCapacity); + } + + /** + * {@link Vector}の新しいインスタンスを作成する。 + * + * @param <E> {@link Vector}の要素型 + * @param initialCapacity {@link Vector}の初期容量 + * @param capacityIncrement {@link Vector}があふれたときに増加される容量 + * @return {@link Vector}の新しいインスタンス + * @see Vector#Vector(int, int) + */ + public static <E>Vector<E> newVector(final int initialCapacity, final int capacityIncrement) { + return new Vector<E>(initialCapacity, capacityIncrement); + } + + /** + * {@link WeakHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link WeakHashMap}のキーの型 + * @param <V> {@link WeakHashMap}の値の型 + * @return {@link WeakHashMap}の新しいインスタンス + * @see WeakHashMap#WeakHashMap() + */ + public static <K, V>WeakHashMap<K, V> newWeakHashMap() { + return new WeakHashMap<K, V>(); + } + + /** + * {@link WeakHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link WeakHashMap}のキーの型 + * @param <V> {@link WeakHashMap}の値の型 + * @param initialCapacity 初期容量 + * @return {@link WeakHashMap}の新しいインスタンス + * @see WeakHashMap#WeakHashMap(int) + */ + public static <K, V>WeakHashMap<K, V> newWeakHashMap(final int initialCapacity) { + return new WeakHashMap<K, V>(initialCapacity); + } + + /** + * {@link WeakHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link WeakHashMap}のキーの型 + * @param <V> {@link WeakHashMap}の値の型 + * @param initialCapacity 初期容量 + * @param loadFactor サイズ変更の制御に使用される負荷係数のしきい値 + * @return {@link WeakHashMap}の新しいインスタンス + * @see WeakHashMap#WeakHashMap(int, float) + */ + public static <K, V>WeakHashMap<K, V> newWeakHashMap(final int initialCapacity, final float loadFactor) { + return new WeakHashMap<K, V>(initialCapacity, loadFactor); + } + + /** + * {@link WeakHashMap}の新しいインスタンスを作成する。 + * + * @param <K> {@link WeakHashMap}のキーの型 + * @param <V> {@link WeakHashMap}の値の型 + * @param m 作成されるマップに配置されるマップ + * @return {@link WeakHashMap}の新しいインスタンス + * @see WeakHashMap#WeakHashMap(Map) + */ + public static <K, V>WeakHashMap<K, V> newWeakHashMap(final Map<? extends K, ? extends V> m) { + return new WeakHashMap<K, V>(m); + } + + /** + * マップが指定されたキーを含んでいない場合は、キーを指定された値に関連付けます。 + * <p> + * マップがすでに指定されたキーを含んでいる場合は、 キーに関連づけられている値を返します。 マップは変更されず、 指定された値は使われません。 + * マップがまだ指定されたキーを含んでいない場合は、 指定された値を値を返します。 マップは変更され、指定されたキーと指定された値が関連づけられます。 + * いずれの場合も、返される値はマップがその時点でキーと関連づけている値です。 + * </p> + * + * @param <K> {@link HashMap}のキーの型 + * @param <V> {@link HashMap}の値の型 + * @param map マップ + * @param key 指定される値が関連付けられるキー + * @param value 指定されるキーに関連付けられる値 + * @return 指定されたキーと関連付けられていた以前の値または、キーに関連付けられる値 + * @see ConcurrentHashMap#putIfAbsent(Object, Object) + */ + public static <K, V>V putIfAbsent(final ConcurrentMap<K, V> map, final K key, final V value) { + V exists = map.putIfAbsent(key, value); + if (exists != null) { + return exists; + } + return value; + } + + private CollectionsUtil() { + throw new JiemamyError("不到達ポイント"); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/CollectionsUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ConstructorUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ConstructorUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ConstructorUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,52 +1,52 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link Constructor}用のユーティリティクラス。 - * - * @author j5ik2o - */ -public class ConstructorUtil { - - /** - * 新しいインスタンスを作成します。 - * - * @param <T> コンストラクタのクラス - * @param constructor コンストラクタ - * @param args コンストラクタの引数 - * @return インスタンス - * @throws InstantiationException インスタンスの生成に失敗した場合 - * @throws IllegalAccessException コンストラクタにアクセスできない場合 - * @throws InvocationTargetException コンストラクタが例外をスローする場合 - */ - public static <T>T newInstance(Constructor<T> constructor, Object[] args) throws InstantiationException, - IllegalAccessException, InvocationTargetException { - return constructor.newInstance(args); - } - - private ConstructorUtil() { - throw new JiemamyError("不到達ポイント"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link Constructor}用のユーティリティクラス。 + * + * @author j5ik2o + */ +public class ConstructorUtil { + + /** + * 新しいインスタンスを作成します。 + * + * @param <T> コンストラクタのクラス + * @param constructor コンストラクタ + * @param args コンストラクタの引数 + * @return インスタンス + * @throws InstantiationException インスタンスの生成に失敗した場合 + * @throws IllegalAccessException コンストラクタにアクセスできない場合 + * @throws InvocationTargetException コンストラクタが例外をスローする場合 + */ + public static <T>T newInstance(Constructor<T> constructor, Object[] args) throws InstantiationException, + IllegalAccessException, InvocationTargetException { + return constructor.newInstance(args); + } + + private ConstructorUtil() { + throw new JiemamyError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ConstructorUtil.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/DateUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/DateUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/DateUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,77 +1,77 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/02/19 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.Calendar; - -import org.apache.commons.lang.Validate; - -/** - * 日付時間系ユーティリティ。 - * - * <p>cf. http://d.hatena.ne.jp/higayasuo/20090219/1235020303</p> - * - * @author daisuke - */ -public class DateUtil { - - /** Unix の「紀元年」 */ - private static final int UNIX_EPOCH = 1970; - - - /** - * {@link java.util.Date}を{@link java.sql.Date}に変換する。 - * - * @param date {@link java.util.Date} - * @return {@link java.sql.Date} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static java.sql.Date toSqlDate(java.util.Date date) { - Validate.notNull(date); - - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - cal.set(Calendar.HOUR_OF_DAY, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - return new java.sql.Date(cal.getTimeInMillis()); - } - - /** - * {@link java.util.Date}を{@link java.sql.Time}に変換する。 - * - * @param date {@link java.util.Date} - * @return {@link java.sql.Time} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static java.sql.Time toSqlTime(java.util.Date date) { - Validate.notNull(date); - - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - cal.set(Calendar.YEAR, UNIX_EPOCH); - cal.set(Calendar.MONTH, Calendar.JANUARY); - cal.set(Calendar.DATE, 1); - return new java.sql.Time(cal.getTimeInMillis()); - } - - private DateUtil() { - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/19 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.Calendar; + +import org.apache.commons.lang.Validate; + +/** + * 日付時間系ユーティリティ。 + * + * <p>cf. http://d.hatena.ne.jp/higayasuo/20090219/1235020303</p> + * + * @author daisuke + */ +public class DateUtil { + + /** Unix の「紀元年」 */ + private static final int UNIX_EPOCH = 1970; + + + /** + * {@link java.util.Date}を{@link java.sql.Date}に変換する。 + * + * @param date {@link java.util.Date} + * @return {@link java.sql.Date} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static java.sql.Date toSqlDate(java.util.Date date) { + Validate.notNull(date); + + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + return new java.sql.Date(cal.getTimeInMillis()); + } + + /** + * {@link java.util.Date}を{@link java.sql.Time}に変換する。 + * + * @param date {@link java.util.Date} + * @return {@link java.sql.Time} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static java.sql.Time toSqlTime(java.util.Date date) { + Validate.notNull(date); + + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.YEAR, UNIX_EPOCH); + cal.set(Calendar.MONTH, Calendar.JANUARY); + cal.set(Calendar.DATE, 1); + return new java.sql.Time(cal.getTimeInMillis()); + } + + private DateUtil() { + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/DateUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/Disposable.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/Disposable.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/Disposable.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,32 +1,32 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 4, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -/** - * リソースを破棄できるインターフェイス。 - * - * @author j5ik2o - */ -public interface Disposable { - - /** - * リソースを破棄する。 - */ - void dispose(); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 4, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +/** + * リソースを破棄できるインターフェイス。 + * + * @author j5ik2o + */ +public interface Disposable { + + /** + * リソースを破棄する。 + */ + void dispose(); +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/Disposable.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/DisposableUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/DisposableUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/DisposableUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,71 +1,71 @@ -/* - * Copyright 2004-2009 the Seasar Foundation and the Others. - * - * 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.jiemamy.utils; - -import java.beans.Introspector; -import java.util.LinkedList; - -import org.jiemamy.exception.JiemamyError; - -/** - * リソースを破棄するためのユーティリティクラス。 - * - * @author j5ik2o - */ -public class DisposableUtil { - - /** 登録済みの{@link Disposable} */ - private static final LinkedList<Disposable> DISPOSABLES = new LinkedList<Disposable>(); - - - /** - * 破棄可能なリソースを登録する。 - * - * @param disposable 破棄可能なリソース - */ - public static synchronized void add(final Disposable disposable) { - DISPOSABLES.add(disposable); - } - - /** - * 登録済みのリソースを全て破棄する。 - */ - public static synchronized void dispose() { - while (DISPOSABLES.isEmpty() == false) { - final Disposable disposable = DISPOSABLES.removeLast(); - try { - disposable.dispose(); - } catch (final Throwable t) { - t.printStackTrace(); // must not use Logger. - } - } - DISPOSABLES.clear(); - Introspector.flushCaches(); - } - - /** - * 破棄可能なリソースの登録を解除する。 - * - * @param disposable 破棄可能なリソース - */ - public static synchronized void remove(final Disposable disposable) { - DISPOSABLES.remove(disposable); - } - - private DisposableUtil() { - throw new JiemamyError("不到達ポイント"); - } -} +/* + * Copyright 2004-2009 the Seasar Foundation and the Others. + * + * 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.jiemamy.utils; + +import java.beans.Introspector; +import java.util.LinkedList; + +import org.jiemamy.exception.JiemamyError; + +/** + * リソースを破棄するためのユーティリティクラス。 + * + * @author j5ik2o + */ +public class DisposableUtil { + + /** 登録済みの{@link Disposable} */ + private static final LinkedList<Disposable> DISPOSABLES = new LinkedList<Disposable>(); + + + /** + * 破棄可能なリソースを登録する。 + * + * @param disposable 破棄可能なリソース + */ + public static synchronized void add(final Disposable disposable) { + DISPOSABLES.add(disposable); + } + + /** + * 登録済みのリソースを全て破棄する。 + */ + public static synchronized void dispose() { + while (DISPOSABLES.isEmpty() == false) { + final Disposable disposable = DISPOSABLES.removeLast(); + try { + disposable.dispose(); + } catch (final Throwable t) { + t.printStackTrace(); // must not use Logger. + } + } + DISPOSABLES.clear(); + Introspector.flushCaches(); + } + + /** + * 破棄可能なリソースの登録を解除する。 + * + * @param disposable 破棄可能なリソース + */ + public static synchronized void remove(final Disposable disposable) { + DISPOSABLES.remove(disposable); + } + + private DisposableUtil() { + throw new JiemamyError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/DisposableUtil.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EnumerationIterator.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EnumerationIterator.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EnumerationIterator.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,58 +1,58 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.Enumeration; -import java.util.Iterator; - -/** - * {@link Enumeration}を {@link Iterator}にするためのアダブタ。 - * - * @param <E> 要素 - * @author j5ik2o - */ -public class EnumerationIterator<E> implements Iterator<E> { - - private Enumeration<E> enumeration = null; - - - /** - * {@link EnumerationIterator}を作成します。 - * - * @param e {@link Enumeration} - */ - public EnumerationIterator(final Enumeration<E> e) { - if (e == null) { - throw new NullPointerException("Enumeration"); - } - this.enumeration = e; - } - - public boolean hasNext() { - return enumeration.hasMoreElements(); - } - - public E next() { - return enumeration.nextElement(); - } - - public void remove() { - throw new UnsupportedOperationException("remove"); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.Enumeration; +import java.util.Iterator; + +/** + * {@link Enumeration}を {@link Iterator}にするためのアダブタ。 + * + * @param <E> 要素 + * @author j5ik2o + */ +public class EnumerationIterator<E> implements Iterator<E> { + + private Enumeration<E> enumeration = null; + + + /** + * {@link EnumerationIterator}を作成します。 + * + * @param e {@link Enumeration} + */ + public EnumerationIterator(final Enumeration<E> e) { + if (e == null) { + throw new NullPointerException("Enumeration"); + } + this.enumeration = e; + } + + public boolean hasNext() { + return enumeration.hasMoreElements(); + } + + public E next() { + return enumeration.nextElement(); + } + + public void remove() { + throw new UnsupportedOperationException("remove"); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EnumerationIterator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialQueue.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialQueue.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialQueue.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,82 +1,82 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/16 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.NoSuchElementException; - -/** - * 本質的なキューのインターフェイス。 - * - * <p>{@link java.util.Queue}は不適切な継承を行っている為、 - * Jiemamy Projectでは、こちらのインターフェイスを優先的に使用する。</p> - * - * @param <E> 要素の型 - * @author daisuke - */ -public interface EssentialQueue<E> extends Iterable<E> { - - /** - * キューを初期化する。 - */ - void clear(); - - /** - * キューから要素を1つ取り出す。 - * - * @return 取り出した要素 - * @throws NoSuchElementException 取り出す要素が無い場合 - */ - E dequeue(); - - /** - * キューに要素を追加する。 - * - * @param element 追加する要素 - */ - void enqueue(E element); - - /** - * 与えられたキューの内容を、このキューに全て追加する。 - * - * @param queue 読み込み元のキュー - */ - void enqueue(EssentialQueue<E> queue); - - /** - * 取り出す要素があるかどうか調べる。 - * - * @return キューが空の場合は{@code true}、そうでない場合は{@code false} - */ - boolean isEmpty(); - - /** - * 次にキューから取り出される要素を取得する。キューから削除は行わない。 - * - * @return 次にキューから取り出される要素 - * @throws NoSuchElementException 取り出す要素が無い場合 - */ - E peek(); - - /** - * キューから取り出せる要素の数を取得する。 - * - * @return 要素の数 - */ - int size(); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/16 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.NoSuchElementException; + +/** + * 本質的なキューのインターフェイス。 + * + * <p>{@link java.util.Queue}は不適切な継承を行っている為、 + * Jiemamy Projectでは、こちらのインターフェイスを優先的に使用する。</p> + * + * @param <E> 要素の型 + * @author daisuke + */ +public interface EssentialQueue<E> extends Iterable<E> { + + /** + * キューを初期化する。 + */ + void clear(); + + /** + * キューから要素を1つ取り出す。 + * + * @return 取り出した要素 + * @throws NoSuchElementException 取り出す要素が無い場合 + */ + E dequeue(); + + /** + * キューに要素を追加する。 + * + * @param element 追加する要素 + */ + void enqueue(E element); + + /** + * 与えられたキューの内容を、このキューに全て追加する。 + * + * @param queue 読み込み元のキュー + */ + void enqueue(EssentialQueue<E> queue); + + /** + * 取り出す要素があるかどうか調べる。 + * + * @return キューが空の場合は{@code true}、そうでない場合は{@code false} + */ + boolean isEmpty(); + + /** + * 次にキューから取り出される要素を取得する。キューから削除は行わない。 + * + * @return 次にキューから取り出される要素 + * @throws NoSuchElementException 取り出す要素が無い場合 + */ + E peek(); + + /** + * キューから取り出せる要素の数を取得する。 + * + * @return 要素の数 + */ + int size(); +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialQueue.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialStack.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialStack.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialStack.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,128 +1,128 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/16 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.EmptyStackException; -import java.util.NoSuchElementException; - -/** - * 本質的なスタックのインターフェイス。 - * - * <p>{@link java.util.Stack}は実装型である上に、不適切な継承を行っている為、 - * Jiemamy Projectでは、こちらのインターフェイスを優先的に使用する。</p> - * - * @param <E> 要素の型 - * @author daisuke - */ -public interface EssentialStack<E> extends Iterable<E> { - - /** - * スタックを初期化する。 - */ - void clear(); - - /** - * n番目にpushされた要素を取得する。スタックから削除は行わない。 - * - * @param n インデックス - * @return 要素 - * @throws IndexOutOfBoundsException if index is out of range {@code (index < 0 || index >= size())}. - */ - E get(int n); - - /** - * スタックの下からn番目に要素を挿入する。 - * - * @param n インデックス - * @param element 挿入する要素 - */ - void insert(int n, E element); - - /** - * 取り出す要素があるかどうか調べる。 - * - * @return スタックが空の場合は{@code true}、そうでない場合は{@code false} - */ - boolean isEmpty(); - - /** - * 次の{@link #pop()}でスタックから取り出される要素を取得する。スタックから削除は行わない。 - * - * <p>{@code peek(0)}と等価である。</p> - * - * @return 要素 - * @throws NoSuchElementException 取り出す要素が無い場合 - */ - E peek(); - - /** - * n番目に{@link #pop()}でスタックから取り出される要素を取得する。スタックから削除は行わない。 - * - * @param n インデックス - * @return 要素 - * @throws EmptyStackException if there are not enough items on the - * stack to satisfy this request - */ - E peek(int n); - - /** - * スタックから要素を1つ取り出す。 - * - * @return 取り出した要素 - * @throws NoSuchElementException 取り出す要素が無い場合 - */ - E pop(); - - /** - * スタックに要素を追加する。 - * - * @param element 追加する要素 - */ - void push(E element); - - /** - * 下から検索し、初めて見つかった要素を削除する。 - * - * @param element 削除する要素 - * @return 削除が行われた場合は{@code true}、そうでない場合は{@code false} - */ - boolean remove(E element); - - /** - * n番目の要素を削除する。 - * - * @param n インデックス - * @return 削除された要素 - */ - E remove(int n); - - /** - * 逆順のスタックを返す。 - * - * @return 逆順のスタック - */ - EssentialStack<E> reverse(); - - /** - * スタックから取り出せる要素の数を取得する。 - * - * @return 要素の数 - */ - int size(); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/16 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.EmptyStackException; +import java.util.NoSuchElementException; + +/** + * 本質的なスタックのインターフェイス。 + * + * <p>{@link java.util.Stack}は実装型である上に、不適切な継承を行っている為、 + * Jiemamy Projectでは、こちらのインターフェイスを優先的に使用する。</p> + * + * @param <E> 要素の型 + * @author daisuke + */ +public interface EssentialStack<E> extends Iterable<E> { + + /** + * スタックを初期化する。 + */ + void clear(); + + /** + * n番目にpushされた要素を取得する。スタックから削除は行わない。 + * + * @param n インデックス + * @return 要素 + * @throws IndexOutOfBoundsException if index is out of range {@code (index < 0 || index >= size())}. + */ + E get(int n); + + /** + * スタックの下からn番目に要素を挿入する。 + * + * @param n インデックス + * @param element 挿入する要素 + */ + void insert(int n, E element); + + /** + * 取り出す要素があるかどうか調べる。 + * + * @return スタックが空の場合は{@code true}、そうでない場合は{@code false} + */ + boolean isEmpty(); + + /** + * 次の{@link #pop()}でスタックから取り出される要素を取得する。スタックから削除は行わない。 + * + * <p>{@code peek(0)}と等価である。</p> + * + * @return 要素 + * @throws NoSuchElementException 取り出す要素が無い場合 + */ + E peek(); + + /** + * n番目に{@link #pop()}でスタックから取り出される要素を取得する。スタックから削除は行わない。 + * + * @param n インデックス + * @return 要素 + * @throws EmptyStackException if there are not enough items on the + * stack to satisfy this request + */ + E peek(int n); + + /** + * スタックから要素を1つ取り出す。 + * + * @return 取り出した要素 + * @throws NoSuchElementException 取り出す要素が無い場合 + */ + E pop(); + + /** + * スタックに要素を追加する。 + * + * @param element 追加する要素 + */ + void push(E element); + + /** + * 下から検索し、初めて見つかった要素を削除する。 + * + * @param element 削除する要素 + * @return 削除が行われた場合は{@code true}、そうでない場合は{@code false} + */ + boolean remove(E element); + + /** + * n番目の要素を削除する。 + * + * @param n インデックス + * @return 削除された要素 + */ + E remove(int n); + + /** + * 逆順のスタックを返す。 + * + * @return 逆順のスタック + */ + EssentialStack<E> reverse(); + + /** + * スタックから取り出せる要素の数を取得する。 + * + * @return 要素の数 + */ + int size(); +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialStack.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialStacks.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialStacks.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialStacks.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,91 +1,91 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/03/04 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import org.apache.commons.lang.ObjectUtils; -import org.apache.commons.lang.Validate; - -/** - * {@link EssentialStack}のユーティリティクラス。 - * - * @author daisuke - */ -public final class EssentialStacks { - - /** - * 左右の要素を下から調べ、初めて異なる要素が現れる所までの部分スタックを返す。 - * - * <p>ABCDEFG と ABCXYZ の場合は ABC を返し、ABCDEFG と ABXDXXG の場合は AB を返す。</p> - * - * @param <E> 要素の型 - * @param left 左辺スタック - * @param right 右辺スタック - * @return 部分スタック - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static <E>EssentialStack<E> intersection(EssentialStack<? extends E> left, EssentialStack<? extends E> right) { - Validate.notNull(left); - Validate.notNull(right); - EssentialStack<E> result = new ArrayEssentialStack<E>(Math.min(left.size(), right.size())); - - int i = 0; - for (E leftElement : left) { - if (i >= right.size()) { - break; - } - E rightElement = right.get(i); - if (ObjectUtils.equals(rightElement, leftElement)) { - result.push(leftElement); - } else { - // 違いが生じた時点で終了 - break; - } - i++; - } - - return result; - } - - /** - * 左の要素から、右の要素を取り除いた部分スタックを返す。 - * - * @param <E> 要素の型 - * @param left 左辺スタック - * @param right 右辺スタック - * @return 部分スタック - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static <E>EssentialStack<E> minus(EssentialStack<? extends E> left, EssentialStack<? extends E> right) { - Validate.notNull(left); - Validate.notNull(right); - EssentialStack<E> result = new ArrayEssentialStack<E>(left); - for (E er : right) { - for (E el : left) { - if (el == er) { - result.remove(el); - } - } - } - - return result; - } - - private EssentialStacks() { - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/03/04 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.commons.lang.Validate; + +/** + * {@link EssentialStack}のユーティリティクラス。 + * + * @author daisuke + */ +public final class EssentialStacks { + + /** + * 左右の要素を下から調べ、初めて異なる要素が現れる所までの部分スタックを返す。 + * + * <p>ABCDEFG と ABCXYZ の場合は ABC を返し、ABCDEFG と ABXDXXG の場合は AB を返す。</p> + * + * @param <E> 要素の型 + * @param left 左辺スタック + * @param right 右辺スタック + * @return 部分スタック + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static <E>EssentialStack<E> intersection(EssentialStack<? extends E> left, EssentialStack<? extends E> right) { + Validate.notNull(left); + Validate.notNull(right); + EssentialStack<E> result = new ArrayEssentialStack<E>(Math.min(left.size(), right.size())); + + int i = 0; + for (E leftElement : left) { + if (i >= right.size()) { + break; + } + E rightElement = right.get(i); + if (ObjectUtils.equals(rightElement, leftElement)) { + result.push(leftElement); + } else { + // 違いが生じた時点で終了 + break; + } + i++; + } + + return result; + } + + /** + * 左の要素から、右の要素を取り除いた部分スタックを返す。 + * + * @param <E> 要素の型 + * @param left 左辺スタック + * @param right 右辺スタック + * @return 部分スタック + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static <E>EssentialStack<E> minus(EssentialStack<? extends E> left, EssentialStack<? extends E> right) { + Validate.notNull(left); + Validate.notNull(right); + EssentialStack<E> result = new ArrayEssentialStack<E>(left); + for (E er : right) { + for (E el : left) { + if (el == er) { + result.remove(el); + } + } + } + + return result; + } + + private EssentialStacks() { + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/EssentialStacks.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FieldUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FieldUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FieldUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,259 +1,259 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; - -import org.apache.commons.lang.Validate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link Field}用のユーティリティクラスです。 - * - * @author j5ik2o - */ -public class FieldUtil { - - @SuppressWarnings("unused") - private static final Logger LOG = LoggerFactory.getLogger(FieldUtil.class); - - /** - * {@link #getElementTypeOfCollectionFromFieldType(Field)}への定数参照です - */ - protected static final Method GET_ELEMENT_TYPE_OF_COLLECTION_FROM_FIELD_TYPE_METHOD = - getElementTypeFromFieldTypeMethod("Collection"); - - /** - * {@link #getElementTypeOfListFromFieldType(Field)}への定数参照です - */ - protected static final Method GET_ELEMENT_TYPE_OF_LIST_FROM_FIELD_TYPE_METHOD = - getElementTypeFromFieldTypeMethod("List"); - - /** - * {@link #getElementTypeOfSetFromFieldType(Field)}への定数参照です - */ - protected static final Method GET_ELEMENT_TYPE_OF_SET_FROM_FIELD_TYPE_METHOD = - getElementTypeFromFieldTypeMethod("Set"); - - - /** - * {@link Field}の値をオブジェクトとして取得する。 - * - * @param field フィールド - * @param target ターゲット - * @return {@link Object} - * @throws IllegalAccessException コンストラクタにアクセスできない場合 - * @throws IllegalArgumentException 引数が正しくない場合 - * @see Field#get(Object) - */ - public static Object get(Field field, Object target) throws IllegalArgumentException, IllegalAccessException { - Validate.notNull(field); - Validate.notNull(target); - return field.get(target); - } - - /** - * <code>ReflectionUtil#getElementTypeOf<var>Xxx</var>FromFieldType()</code> - * の {@link Method}を取得する。 - * - * @param type 取得するメソッドが対象とする型名 - * @return - * <code>ReflectionUtil#getElementTypeOf<var>Xxx</var>FromFieldType()</code> - * の{@link Method} - */ - protected static Method getElementTypeFromFieldTypeMethod(final String type) { - Validate.notNull(type); - try { - final Class<?> reflectionUtilClass = ReflectionUtil.class; - return reflectionUtilClass.getMethod("getElementTypeOf" + type + "FromFieldType", new Class[] { - Field.class - }); - } catch (Throwable ignore) { - //ignore - } - return null; - } - - /** - * 指定されたフィールドのパラメタ化されたコレクションの要素型を取得する。 - * - * @param field フィールド - * @return フィールドのパラメタ化されたコレクションの要素型 - */ - public static Class<?> getElementTypeOfCollectionFromFieldType(final Field field) { - Validate.notNull(field); - try { - return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_COLLECTION_FROM_FIELD_TYPE_METHOD, null, - new Object[] { - field - }); - } catch (Throwable ignore) { - //ignore - } - return null; - } - - /** - * 指定されたフィールドのパラメタ化されたリストの要素型を取得する。 - * - * @param field フィールド - * @return フィールドのパラメタ化されたリストの要素型 - */ - public static Class<?> getElementTypeOfListFromFieldType(final Field field) { - Validate.notNull(field); - try { - return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_LIST_FROM_FIELD_TYPE_METHOD, null, new Object[] { - field - }); - } catch (Throwable ignore) { - //ignore - } - return null; - } - - /** - * 指定されたフィールドのパラメタ化されたセットの要素型を取得する。 - * - * @param field フィールド - * @return フィールドのパラメタ化されたセットの要素型 - */ - public static Class<?> getElementTypeOfSetFromFieldType(final Field field) { - Validate.notNull(field); - try { - return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_SET_FROM_FIELD_TYPE_METHOD, null, new Object[] { - field - }); - } catch (Throwable ignore) { - //ignore - } - return null; - } - - /** - * staticな {@link Field}の値をintとして取得する。 - * - * @param field フィールド - * @return intの値 - * @throws IllegalAccessException フィールドにアクセスできない場合 - * @throws IllegalArgumentException フィールドを宣言するクラスまたはインタフェースのインスタンスではない場合 - * @see #getInt(Field, Object) - */ - public static int getInt(Field field) throws IllegalArgumentException, IllegalAccessException { - Validate.notNull(field); - return getInt(field, null); - } - - /** - * {@link Field}の値をintとして取得する。 - * - * @param field フィールド - * @param target ターゲット - * @return intの値 - * @throws IllegalAccessException フィールドにアクセスできない場合 - * @throws IllegalArgumentException フィールドを宣言するクラスまたはインタフェースのインスタンスではない場合 - * @see Field#getInt(Object) - */ - public static int getInt(Field field, Object target) throws IllegalArgumentException, IllegalAccessException { - Validate.notNull(field); - Validate.notNull(target); - return field.getInt(target); - } - - /** - * staticな {@link Field}の値を {@link String}として取得する。 - * - * @param field フィールド - * @return {@link String}の値 - * @throws IllegalAccessException フィールドにアクセスできない場合 - * @throws IllegalArgumentException フィールドを宣言するクラスまたはインタフェースのインスタンスではない場合 - * @see #getString(Field, Object) - */ - public static String getString(Field field) throws IllegalArgumentException, IllegalAccessException { - Validate.notNull(field); - return getString(field, null); - } - - /** - * {@link Field}の値を {@link String}として取得する。 - * - * @param field フィールド - * @param target ターゲット - * @return {@link String}の値 - * @throws IllegalAccessException フィールドにアクセスできない場合 - * @throws IllegalArgumentException フィールドを宣言するクラスまたはインタフェースのインスタンスではない場合 - * @see Field#get(Object) - */ - public static String getString(Field field, Object target) throws IllegalArgumentException, IllegalAccessException { - Validate.notNull(field); - Validate.notNull(target); - return (String) field.get(target); - } - - /** - * インスタンスフィールドがどうかを取得する。 - * - * @param field フィールド - * @return インスタンスフィールドかどうか - */ - public static boolean isInstanceField(Field field) { - Validate.notNull(field); - int mod = field.getModifiers(); - return !Modifier.isStatic(mod) && !Modifier.isFinal(mod); - } - - /** - * パブリックフィールドかどうかを取得する。 - * - * @param field フィールド - * @return パブリックフィールドかどうか - */ - public static boolean isPublicField(Field field) { - Validate.notNull(field); - int mod = field.getModifiers(); - return Modifier.isPublic(mod); - } - - /** - * {@link Field}に値を設定する。 - * - * @param field フィールド - * @param target ターゲット - * @param value 値 - * @throws IllegalAccessException フィールドにアクセスできない場合 - * @throws IllegalArgumentException フィールドを宣言するクラスまたはインタフェースのインスタンスではない場合 - * あるいはラップ解除変換が失敗した場合 - * @see Field#set(Object, Object) - */ - public static void set(Field field, Object target, Object value) throws IllegalArgumentException, - IllegalAccessException { - Validate.notNull(field); - Validate.notNull(target); - Validate.notNull(value); - field.set(target, value); - } - - private FieldUtil() { - throw new JiemamyError("不到達ポイント"); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +import org.apache.commons.lang.Validate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link Field}用のユーティリティクラスです。 + * + * @author j5ik2o + */ +public class FieldUtil { + + @SuppressWarnings("unused") + private static final Logger LOG = LoggerFactory.getLogger(FieldUtil.class); + + /** + * {@link #getElementTypeOfCollectionFromFieldType(Field)}への定数参照です + */ + protected static final Method GET_ELEMENT_TYPE_OF_COLLECTION_FROM_FIELD_TYPE_METHOD = + getElementTypeFromFieldTypeMethod("Collection"); + + /** + * {@link #getElementTypeOfListFromFieldType(Field)}への定数参照です + */ + protected static final Method GET_ELEMENT_TYPE_OF_LIST_FROM_FIELD_TYPE_METHOD = + getElementTypeFromFieldTypeMethod("List"); + + /** + * {@link #getElementTypeOfSetFromFieldType(Field)}への定数参照です + */ + protected static final Method GET_ELEMENT_TYPE_OF_SET_FROM_FIELD_TYPE_METHOD = + getElementTypeFromFieldTypeMethod("Set"); + + + /** + * {@link Field}の値をオブジェクトとして取得する。 + * + * @param field フィールド + * @param target ターゲット + * @return {@link Object} + * @throws IllegalAccessException コンストラクタにアクセスできない場合 + * @throws IllegalArgumentException 引数が正しくない場合 + * @see Field#get(Object) + */ + public static Object get(Field field, Object target) throws IllegalArgumentException, IllegalAccessException { + Validate.notNull(field); + Validate.notNull(target); + return field.get(target); + } + + /** + * <code>ReflectionUtil#getElementTypeOf<var>Xxx</var>FromFieldType()</code> + * の {@link Method}を取得する。 + * + * @param type 取得するメソッドが対象とする型名 + * @return + * <code>ReflectionUtil#getElementTypeOf<var>Xxx</var>FromFieldType()</code> + * の{@link Method} + */ + protected static Method getElementTypeFromFieldTypeMethod(final String type) { + Validate.notNull(type); + try { + final Class<?> reflectionUtilClass = ReflectionUtil.class; + return reflectionUtilClass.getMethod("getElementTypeOf" + type + "FromFieldType", new Class[] { + Field.class + }); + } catch (Throwable ignore) { + //ignore + } + return null; + } + + /** + * 指定されたフィールドのパラメタ化されたコレクションの要素型を取得する。 + * + * @param field フィールド + * @return フィールドのパラメタ化されたコレクションの要素型 + */ + public static Class<?> getElementTypeOfCollectionFromFieldType(final Field field) { + Validate.notNull(field); + try { + return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_COLLECTION_FROM_FIELD_TYPE_METHOD, null, + new Object[] { + field + }); + } catch (Throwable ignore) { + //ignore + } + return null; + } + + /** + * 指定されたフィールドのパラメタ化されたリストの要素型を取得する。 + * + * @param field フィールド + * @return フィールドのパラメタ化されたリストの要素型 + */ + public static Class<?> getElementTypeOfListFromFieldType(final Field field) { + Validate.notNull(field); + try { + return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_LIST_FROM_FIELD_TYPE_METHOD, null, new Object[] { + field + }); + } catch (Throwable ignore) { + //ignore + } + return null; + } + + /** + * 指定されたフィールドのパラメタ化されたセットの要素型を取得する。 + * + * @param field フィールド + * @return フィールドのパラメタ化されたセットの要素型 + */ + public static Class<?> getElementTypeOfSetFromFieldType(final Field field) { + Validate.notNull(field); + try { + return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_SET_FROM_FIELD_TYPE_METHOD, null, new Object[] { + field + }); + } catch (Throwable ignore) { + //ignore + } + return null; + } + + /** + * staticな {@link Field}の値をintとして取得する。 + * + * @param field フィールド + * @return intの値 + * @throws IllegalAccessException フィールドにアクセスできない場合 + * @throws IllegalArgumentException フィールドを宣言するクラスまたはインタフェースのインスタンスではない場合 + * @see #getInt(Field, Object) + */ + public static int getInt(Field field) throws IllegalArgumentException, IllegalAccessException { + Validate.notNull(field); + return getInt(field, null); + } + + /** + * {@link Field}の値をintとして取得する。 + * + * @param field フィールド + * @param target ターゲット + * @return intの値 + * @throws IllegalAccessException フィールドにアクセスできない場合 + * @throws IllegalArgumentException フィールドを宣言するクラスまたはインタフェースのインスタンスではない場合 + * @see Field#getInt(Object) + */ + public static int getInt(Field field, Object target) throws IllegalArgumentException, IllegalAccessException { + Validate.notNull(field); + Validate.notNull(target); + return field.getInt(target); + } + + /** + * staticな {@link Field}の値を {@link String}として取得する。 + * + * @param field フィールド + * @return {@link String}の値 + * @throws IllegalAccessException フィールドにアクセスできない場合 + * @throws IllegalArgumentException フィールドを宣言するクラスまたはインタフェースのインスタンスではない場合 + * @see #getString(Field, Object) + */ + public static String getString(Field field) throws IllegalArgumentException, IllegalAccessException { + Validate.notNull(field); + return getString(field, null); + } + + /** + * {@link Field}の値を {@link String}として取得する。 + * + * @param field フィールド + * @param target ターゲット + * @return {@link String}の値 + * @throws IllegalAccessException フィールドにアクセスできない場合 + * @throws IllegalArgumentException フィールドを宣言するクラスまたはインタフェースのインスタンスではない場合 + * @see Field#get(Object) + */ + public static String getString(Field field, Object target) throws IllegalArgumentException, IllegalAccessException { + Validate.notNull(field); + Validate.notNull(target); + return (String) field.get(target); + } + + /** + * インスタンスフィールドがどうかを取得する。 + * + * @param field フィールド + * @return インスタンスフィールドかどうか + */ + public static boolean isInstanceField(Field field) { + Validate.notNull(field); + int mod = field.getModifiers(); + return !Modifier.isStatic(mod) && !Modifier.isFinal(mod); + } + + /** + * パブリックフィールドかどうかを取得する。 + * + * @param field フィールド + * @return パブリックフィールドかどうか + */ + public static boolean isPublicField(Field field) { + Validate.notNull(field); + int mod = field.getModifiers(); + return Modifier.isPublic(mod); + } + + /** + * {@link Field}に値を設定する。 + * + * @param field フィールド + * @param target ターゲット + * @param value 値 + * @throws IllegalAccessException フィールドにアクセスできない場合 + * @throws IllegalArgumentException フィールドを宣言するクラスまたはインタフェースのインスタンスではない場合 + * あるいはラップ解除変換が失敗した場合 + * @see Field#set(Object, Object) + */ + public static void set(Field field, Object target, Object value) throws IllegalArgumentException, + IllegalAccessException { + Validate.notNull(field); + Validate.notNull(target); + Validate.notNull(value); + field.set(target, value); + } + + private FieldUtil() { + throw new JiemamyError("不到達ポイント"); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FieldUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileInputStreamUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileInputStreamUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileInputStreamUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,50 +1,50 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link FileInputStream}用のユーティリティクラス。 - * - * @author j5ik2o - * - */ -public class FileInputStreamUtil { - - /** - * {@link FileInputStream}を作成する。 - * - * @param file ファイル - * @return {@link FileInputStream} - * @throws FileNotFoundException ファイルが存在しないか、 - * 普通のファイルではなくディレクトリであるか、またはなんらかの理由で開くことができない場合 - * @see FileInputStream#FileInputStream(File) - */ - public static FileInputStream create(File file) throws FileNotFoundException { - return new FileInputStream(file); - } - - private FileInputStreamUtil() { - throw new JiemamyError("不到達ポイント"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link FileInputStream}用のユーティリティクラス。 + * + * @author j5ik2o + * + */ +public class FileInputStreamUtil { + + /** + * {@link FileInputStream}を作成する。 + * + * @param file ファイル + * @return {@link FileInputStream} + * @throws FileNotFoundException ファイルが存在しないか、 + * 普通のファイルではなくディレクトリであるか、またはなんらかの理由で開くことができない場合 + * @see FileInputStream#FileInputStream(File) + */ + public static FileInputStream create(File file) throws FileNotFoundException { + return new FileInputStream(file); + } + + private FileInputStreamUtil() { + throw new JiemamyError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileInputStreamUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileOutputStreamUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileOutputStreamUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileOutputStreamUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,50 +1,50 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link FileOutputStream}用のユーティリティクラス。 - * - * @author j5ik2o - * - */ -public class FileOutputStreamUtil { - - /** - * {@link FileOutputStream}を作成する。 - * - * @param file ファイル - * @return {@link FileOutputStream} - * @throws FileNotFoundException ファイルは存在するが、普通のファイルではなくディレクトリである場合、 - * ファイルは存在せず作成もできない場合、またはなんらかの理由で開くことができない場合 - * @see FileOutputStream#FileOutputStream(File) - */ - public static FileOutputStream create(File file) throws FileNotFoundException { - return new FileOutputStream(file); - } - - private FileOutputStreamUtil() { - throw new JiemamyError("不到達ポイント"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link FileOutputStream}用のユーティリティクラス。 + * + * @author j5ik2o + * + */ +public class FileOutputStreamUtil { + + /** + * {@link FileOutputStream}を作成する。 + * + * @param file ファイル + * @return {@link FileOutputStream} + * @throws FileNotFoundException ファイルは存在するが、普通のファイルではなくディレクトリである場合、 + * ファイルは存在せず作成もできない場合、またはなんらかの理由で開くことができない場合 + * @see FileOutputStream#FileOutputStream(File) + */ + public static FileOutputStream create(File file) throws FileNotFoundException { + return new FileOutputStream(file); + } + + private FileOutputStreamUtil() { + throw new JiemamyError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileOutputStreamUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,147 +1,147 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link File}を扱うユーティリティ・クラス。 - * - * @author j5ik2o - */ -public class FileUtil { - - /** バッファサイズ */ - private static final int BUFF_SIZE = 1024; - - - /** - * <code>src</code>の内容を<code>dest</code>にコピーします。 - * - * @param src コピー元のファイル - * @param dest コピー先のファイル - * @throws IOException 入出力に失敗した場合 - */ - public static void copy(File src, File dest) throws IOException { - Validate.notNull(src); - Validate.notNull(dest); - if (dest.canWrite() == false || (dest.exists() && dest.canWrite() == false)) { - return; - } - BufferedInputStream in = null; - BufferedOutputStream out = null; - try { - in = new BufferedInputStream(FileInputStreamUtil.create(src)); - out = new BufferedOutputStream(FileOutputStreamUtil.create(dest)); - byte[] buf = new byte[BUFF_SIZE]; - int length; - while (-1 < (length = in.read(buf))) { - out.write(buf, 0, length); - out.flush(); - } - } finally { - InputStreamUtil.close(in); - OutputStreamUtil.close(out); - } - } - - /** - * ファイルの内容をバイト配列に読み込む。 - * - * @param file ファイル - * @return ファイルの内容を読み込んだバイト配列 - * @throws IOException 入出力が失敗した場合 - */ - public static byte[] getBytes(File file) throws IOException { - Validate.notNull(file); - return InputStreamUtil.getBytes(FileInputStreamUtil.create(file)); - } - - /** - * この抽象パス名の正規の形式を返します。 - * - * @param file ファイル - * @return この抽象パス名と同じファイルまたはディレクトリを示す正規パス名文字列 - * @throws IOException 入出力が失敗した場合 - */ - public static String getCanonicalPath(File file) throws IOException { - Validate.notNull(file); - return file.getCanonicalPath(); - } - - /** - * この抽象パス名を<code>file:</code> URLに変換します。 - * - * @param file ファイル - * @return ファイルURLを表すURLオブジェクト - * @throws MalformedURLException 無効な書式のURLが発生した場合 - */ - public static URL toURL(final File file) throws MalformedURLException { - Validate.notNull(file); - return file.toURI().toURL(); - } - - /** - * バイトの配列をファイルに書き出します。 - * - * @param path ファイルのパス - * @param data バイトの配列 - * @throws IOException 入出力が失敗した場合 - * @throws NullPointerException pathやdataがnullの場合。 - */ - public static void write(String path, byte[] data) throws IOException { - Validate.notNull(path); - Validate.notNull(data); - write(path, data, 0, data.length); - } - - /** - * バイトの配列をファイルに書き出します。 - * - * @param path ファイルのパス - * @param data バイトの配列 - * @param offset オフセット - * @param length 配列の長さ - * @throws IOException 入出力が失敗した場合 - */ - public static void write(String path, byte[] data, int offset, int length) throws IOException { - Validate.notNull(path); - Validate.notNull(data); - OutputStream out = new BufferedOutputStream(new FileOutputStream(path)); - try { - out.write(data, offset, length); - } finally { - out.close(); - } - } - - private FileUtil() { - throw new JiemamyError("不到達ポイント"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.net.URL; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link File}を扱うユーティリティ・クラス。 + * + * @author j5ik2o + */ +public class FileUtil { + + /** バッファサイズ */ + private static final int BUFF_SIZE = 1024; + + + /** + * <code>src</code>の内容を<code>dest</code>にコピーします。 + * + * @param src コピー元のファイル + * @param dest コピー先のファイル + * @throws IOException 入出力に失敗した場合 + */ + public static void copy(File src, File dest) throws IOException { + Validate.notNull(src); + Validate.notNull(dest); + if (dest.canWrite() == false || (dest.exists() && dest.canWrite() == false)) { + return; + } + BufferedInputStream in = null; + BufferedOutputStream out = null; + try { + in = new BufferedInputStream(FileInputStreamUtil.create(src)); + out = new BufferedOutputStream(FileOutputStreamUtil.create(dest)); + byte[] buf = new byte[BUFF_SIZE]; + int length; + while (-1 < (length = in.read(buf))) { + out.write(buf, 0, length); + out.flush(); + } + } finally { + InputStreamUtil.close(in); + OutputStreamUtil.close(out); + } + } + + /** + * ファイルの内容をバイト配列に読み込む。 + * + * @param file ファイル + * @return ファイルの内容を読み込んだバイト配列 + * @throws IOException 入出力が失敗した場合 + */ + public static byte[] getBytes(File file) throws IOException { + Validate.notNull(file); + return InputStreamUtil.getBytes(FileInputStreamUtil.create(file)); + } + + /** + * この抽象パス名の正規の形式を返します。 + * + * @param file ファイル + * @return この抽象パス名と同じファイルまたはディレクトリを示す正規パス名文字列 + * @throws IOException 入出力が失敗した場合 + */ + public static String getCanonicalPath(File file) throws IOException { + Validate.notNull(file); + return file.getCanonicalPath(); + } + + /** + * この抽象パス名を<code>file:</code> URLに変換します。 + * + * @param file ファイル + * @return ファイルURLを表すURLオブジェクト + * @throws MalformedURLException 無効な書式のURLが発生した場合 + */ + public static URL toURL(final File file) throws MalformedURLException { + Validate.notNull(file); + return file.toURI().toURL(); + } + + /** + * バイトの配列をファイルに書き出します。 + * + * @param path ファイルのパス + * @param data バイトの配列 + * @throws IOException 入出力が失敗した場合 + * @throws NullPointerException pathやdataがnullの場合。 + */ + public static void write(String path, byte[] data) throws IOException { + Validate.notNull(path); + Validate.notNull(data); + write(path, data, 0, data.length); + } + + /** + * バイトの配列をファイルに書き出します。 + * + * @param path ファイルのパス + * @param data バイトの配列 + * @param offset オフセット + * @param length 配列の長さ + * @throws IOException 入出力が失敗した場合 + */ + public static void write(String path, byte[] data, int offset, int length) throws IOException { + Validate.notNull(path); + Validate.notNull(data); + OutputStream out = new BufferedOutputStream(new FileOutputStream(path)); + try { + out.write(data, offset, length); + } finally { + out.close(); + } + } + + private FileUtil() { + throw new JiemamyError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/FileUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ForEachUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ForEachUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ForEachUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,257 +1,257 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/06/25 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.utils.metadata.TypeSafeDatabaseMetaData.TypeSafeResultSet; - -/** - * {@link Collection}や{@link Map}等、複数の要素を持つObjectに対して、全ての要素に処理を行うためのユーティリティ。 - * - * @author daisuke - */ -public final class ForEachUtil { - - /** - * {@link Collection}を処理するビジターアクセプタメソッド。 - * - * @param <T> Collectionが持つオブジェクトの型 - * @param <R> 戻り値の型 - * @param <X> visitメソッドが投げる可能性のある例外 - * @param target 処理対象コレクション - * @param visitor ビジター - * @return accept結果 - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static <T, R, X extends Exception>R accept(Iterable<T> target, CollectionVisitor<T, R, X> visitor) throws X { - Validate.notNull(target); - Validate.notNull(visitor); - - Iterator<T> iterator = target.iterator(); - while (iterator.hasNext()) { - T element = iterator.next(); - R result = visitor.visit(element); - if (result != null) { - return result; - } - } - return visitor.getFinalResult(); - } - - /** - * {@link Map}を処理するビジターアクセプタメソッド。 - * - * @param <K> Mapのキーの型 - * @param <V> Mapの値の型 - * @param <R> 戻り値の型 - * @param <X> visitメソッドが投げる可能性のある例外 - * @param targetMap 処理対象コレクション - * @param visitor ビジター - * @return accept結果 - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static <K, V, R, X extends Exception>R accept(Map<K, V> targetMap, MapVisitor<K, V, R, X> visitor) throws X { - Validate.notNull(targetMap); - Validate.notNull(visitor); - - for (Map.Entry<K, V> entry : targetMap.entrySet()) { - R result = visitor.visit(entry.getKey(), entry.getValue()); - if (result != null) { - return result; - } - } - return visitor.getFinalResult(); - } - - /** - * {@link ResultSet}を処理するビジターアクセプタメソッド。 - * - * @param <R> 戻り値の型 - * @param <X> visitメソッドが投げる可能性のある例外 - * @param target 処理対象ResultSet - * @param visitor ビジター - * @return accept結果 - * @throws SQLException SQLの実行に失敗した場合 - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static <R, X extends Exception>R accept(ResultSet target, ResultSetVisitor<ResultSet, R, X> visitor) - throws SQLException, X { // CHECKSTYLE IGNORE THIS LINE - Validate.notNull(target); - Validate.notNull(visitor); - - while (target.next()) { - visitor.visit(target); - } - return visitor.getFinalResult(); - } - - /** - * {@link TypeSafeResultSet}を処理するビジターアクセプタメソッド。 - * - * @param <T> {@link TypeSafeResultSet}が返す型 - * @param <R> 戻り値の型 - * @param <X> visitメソッドが投げる可能性のある例外 - * @param target 処理対象TypeSafeResultSet - * @param visitor ビジター - * @return accept結果 - * @throws SQLException SQLの実行に失敗した場合 - * @throws X ビジターにより指定された例外がスローされた場合 - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static <T, R, X extends Exception>R accept(TypeSafeResultSet<T> target, - TypeSafeResultSetVisitor<T, R, X> visitor) throws SQLException, X { // CHECKSTYLE IGNORE THIS LINE - Validate.notNull(target); - Validate.notNull(visitor); - - while (target.next()) { - visitor.visit(target.getResult()); - } - return visitor.getFinalResult(); - } - - /** - * ユーティリティクラス。 - */ - private ForEachUtil() { - } - - - /** - * {@link Collection}に対するビジター。 - * - * @param <T> {@link Collection}が保持する型 - * @param <R> acceptが返すべき戻り値の型 - * @param <X> visitメソッドが投げる可能性のある例外 - * @author daisuke - */ - public static interface CollectionVisitor<T, R, X extends Exception> { - - /** - * ループが終了した後、acceptが返すべき戻り値を取得する。 - * - * @return ループが終了した後、acceptが返すべき戻り値 - */ - R getFinalResult(); - - /** - * 処理内容を記述するメソッド。 - * - * @param element 処理対象要素 - * @return 引き続きacceptを継続する場合null、ループを終了する場合acceptが返すべき戻り値を返す。 - * @throws X ビジタが指定した例外が発生した場合 - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - R visit(T element) throws X; - } - - /** - * {@link Map}に対するビジター。 - * - * @param <K> 処理対象{@link Map}のキーの型 - * @param <V> 処理対象{@link Map}の値の型 - * @param <R> forEachが返すべき戻り値の型 - * @param <X> visitメソッドが投げる可能性のある例外 - * @author daisuke - */ - public static interface MapVisitor<K, V, R, X extends Exception> { - - /** - * ループが終了した後、acceptが返すべき戻り値を取得する。 - * - * @return ループが終了した後、acceptが返すべき戻り値 - */ - R getFinalResult(); - - /** - * 処理内容を記述するメソッド。 - * - * @param key 処理対象のキー - * @param value 処理対象の値 - * @return 引き続きacceptを継続する場合null、ループを終了する場合acceptが返すべき戻り値を返す。 - * @throws X ビジタが指定した例外が発生した場合 - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - R visit(K key, V value) throws X; - } - - /** - * {@link ResultSet}に対するビジター。 - * - * @param <T> ビジターが受け取る要素の型 - * @param <R> forEachが返すべき戻り値の型 - * @param <X> visitメソッドが投げる可能性のある例外 - * @author daisuke - */ - public static interface ResultSetVisitor<T, R, X extends Exception> { - - /** - * ループが終了した後、acceptが返すべき戻り値を取得する。 - * - * @return ループが終了した後、acceptが返すべき戻り値 - */ - R getFinalResult(); - - /** - * 処理内容を記述するメソッド。 - * - * @param element 処理対象要素 - * @return 引き続きacceptを継続する場合null、ループを終了する場合acceptが返すべき戻り値を返す。 - * @throws X ビジタが指定した例外が発生した場合 - * @throws SQLException SQLの実行に失敗した場合 - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - R visit(T element) throws SQLException, X; - } - - /** - * {@link TypeSafeResultSet}に対するビジター。 - * - * @param <T> ビジターが受け取る要素の型 - * @param <R> forEachが返すべき戻り値の型 - * @param <X> visitメソッドが投げる可能性のある例外 - * @author daisuke - */ - public static interface TypeSafeResultSetVisitor<T, R, X extends Exception> { - - /** - * ループが終了した後、acceptが返すべき戻り値を取得する。 - * - * @return ループが終了した後、acceptが返すべき戻り値 - */ - R getFinalResult(); - - /** - * 処理内容を記述するメソッド。 - * - * @param element 処理対象要素 - * @return 引き続きacceptを継続する場合null、ループを終了する場合acceptが返すべき戻り値を返す。 - * @throws X ビジタが指定した例外が発生した場合 - * @throws SQLException SQLの実行に失敗した場合 - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - R visit(T element) throws SQLException, X; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/06/25 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Collection; +import java.util.Iterator; +import java.util.Map; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.utils.metadata.TypeSafeDatabaseMetaData.TypeSafeResultSet; + +/** + * {@link Collection}や{@link Map}等、複数の要素を持つObjectに対して、全ての要素に処理を行うためのユーティリティ。 + * + * @author daisuke + */ +public final class ForEachUtil { + + /** + * {@link Collection}を処理するビジターアクセプタメソッド。 + * + * @param <T> Collectionが持つオブジェクトの型 + * @param <R> 戻り値の型 + * @param <X> visitメソッドが投げる可能性のある例外 + * @param target 処理対象コレクション + * @param visitor ビジター + * @return accept結果 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static <T, R, X extends Exception>R accept(Iterable<T> target, CollectionVisitor<T, R, X> visitor) throws X { + Validate.notNull(target); + Validate.notNull(visitor); + + Iterator<T> iterator = target.iterator(); + while (iterator.hasNext()) { + T element = iterator.next(); + R result = visitor.visit(element); + if (result != null) { + return result; + } + } + return visitor.getFinalResult(); + } + + /** + * {@link Map}を処理するビジターアクセプタメソッド。 + * + * @param <K> Mapのキーの型 + * @param <V> Mapの値の型 + * @param <R> 戻り値の型 + * @param <X> visitメソッドが投げる可能性のある例外 + * @param targetMap 処理対象コレクション + * @param visitor ビジター + * @return accept結果 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static <K, V, R, X extends Exception>R accept(Map<K, V> targetMap, MapVisitor<K, V, R, X> visitor) throws X { + Validate.notNull(targetMap); + Validate.notNull(visitor); + + for (Map.Entry<K, V> entry : targetMap.entrySet()) { + R result = visitor.visit(entry.getKey(), entry.getValue()); + if (result != null) { + return result; + } + } + return visitor.getFinalResult(); + } + + /** + * {@link ResultSet}を処理するビジターアクセプタメソッド。 + * + * @param <R> 戻り値の型 + * @param <X> visitメソッドが投げる可能性のある例外 + * @param target 処理対象ResultSet + * @param visitor ビジター + * @return accept結果 + * @throws SQLException SQLの実行に失敗した場合 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static <R, X extends Exception>R accept(ResultSet target, ResultSetVisitor<ResultSet, R, X> visitor) + throws SQLException, X { // CHECKSTYLE IGNORE THIS LINE + Validate.notNull(target); + Validate.notNull(visitor); + + while (target.next()) { + visitor.visit(target); + } + return visitor.getFinalResult(); + } + + /** + * {@link TypeSafeResultSet}を処理するビジターアクセプタメソッド。 + * + * @param <T> {@link TypeSafeResultSet}が返す型 + * @param <R> 戻り値の型 + * @param <X> visitメソッドが投げる可能性のある例外 + * @param target 処理対象TypeSafeResultSet + * @param visitor ビジター + * @return accept結果 + * @throws SQLException SQLの実行に失敗した場合 + * @throws X ビジターにより指定された例外がスローされた場合 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static <T, R, X extends Exception>R accept(TypeSafeResultSet<T> target, + TypeSafeResultSetVisitor<T, R, X> visitor) throws SQLException, X { // CHECKSTYLE IGNORE THIS LINE + Validate.notNull(target); + Validate.notNull(visitor); + + while (target.next()) { + visitor.visit(target.getResult()); + } + return visitor.getFinalResult(); + } + + /** + * ユーティリティクラス。 + */ + private ForEachUtil() { + } + + + /** + * {@link Collection}に対するビジター。 + * + * @param <T> {@link Collection}が保持する型 + * @param <R> acceptが返すべき戻り値の型 + * @param <X> visitメソッドが投げる可能性のある例外 + * @author daisuke + */ + public static interface CollectionVisitor<T, R, X extends Exception> { + + /** + * ループが終了した後、acceptが返すべき戻り値を取得する。 + * + * @return ループが終了した後、acceptが返すべき戻り値 + */ + R getFinalResult(); + + /** + * 処理内容を記述するメソッド。 + * + * @param element 処理対象要素 + * @return 引き続きacceptを継続する場合null、ループを終了する場合acceptが返すべき戻り値を返す。 + * @throws X ビジタが指定した例外が発生した場合 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + R visit(T element) throws X; + } + + /** + * {@link Map}に対するビジター。 + * + * @param <K> 処理対象{@link Map}のキーの型 + * @param <V> 処理対象{@link Map}の値の型 + * @param <R> forEachが返すべき戻り値の型 + * @param <X> visitメソッドが投げる可能性のある例外 + * @author daisuke + */ + public static interface MapVisitor<K, V, R, X extends Exception> { + + /** + * ループが終了した後、acceptが返すべき戻り値を取得する。 + * + * @return ループが終了した後、acceptが返すべき戻り値 + */ + R getFinalResult(); + + /** + * 処理内容を記述するメソッド。 + * + * @param key 処理対象のキー + * @param value 処理対象の値 + * @return 引き続きacceptを継続する場合null、ループを終了する場合acceptが返すべき戻り値を返す。 + * @throws X ビジタが指定した例外が発生した場合 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + R visit(K key, V value) throws X; + } + + /** + * {@link ResultSet}に対するビジター。 + * + * @param <T> ビジターが受け取る要素の型 + * @param <R> forEachが返すべき戻り値の型 + * @param <X> visitメソッドが投げる可能性のある例外 + * @author daisuke + */ + public static interface ResultSetVisitor<T, R, X extends Exception> { + + /** + * ループが終了した後、acceptが返すべき戻り値を取得する。 + * + * @return ループが終了した後、acceptが返すべき戻り値 + */ + R getFinalResult(); + + /** + * 処理内容を記述するメソッド。 + * + * @param element 処理対象要素 + * @return 引き続きacceptを継続する場合null、ループを終了する場合acceptが返すべき戻り値を返す。 + * @throws X ビジタが指定した例外が発生した場合 + * @throws SQLException SQLの実行に失敗した場合 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + R visit(T element) throws SQLException, X; + } + + /** + * {@link TypeSafeResultSet}に対するビジター。 + * + * @param <T> ビジターが受け取る要素の型 + * @param <R> forEachが返すべき戻り値の型 + * @param <X> visitメソッドが投げる可能性のある例外 + * @author daisuke + */ + public static interface TypeSafeResultSetVisitor<T, R, X extends Exception> { + + /** + * ループが終了した後、acceptが返すべき戻り値を取得する。 + * + * @return ループが終了した後、acceptが返すべき戻り値 + */ + R getFinalResult(); + + /** + * 処理内容を記述するメソッド。 + * + * @param element 処理対象要素 + * @return 引き続きacceptを継続する場合null、ループを終了する場合acceptが返すべき戻り値を返す。 + * @throws X ビジタが指定した例外が発生した場合 + * @throws SQLException SQLの実行に失敗した場合 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + R visit(T element) throws SQLException, X; + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ForEachUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/GenericUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/GenericUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/GenericUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,478 +1,478 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.lang.reflect.Array; -import java.lang.reflect.GenericArrayType; -import java.lang.reflect.GenericDeclaration; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; -import java.lang.reflect.WildcardType; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.jiemamy.exception.JiemamyError; - -/** - * Genericsを扱うためのユーティリティ・クラス。 - * - * @author j5ik2o - */ -public abstract class GenericUtil { - - /** - * パラメータ化された型(クラスまたはインタフェース)が持つ型変数および型引数を集めて<code>map</code>に追加する。 - * - * @param clazz クラス - * @param type 型 - * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} - */ - protected static void gatherTypeVariables(final Class<?> clazz, final Type type, - final Map<TypeVariable<?>, Type> map) { - if (clazz == null) { - return; - } - gatherTypeVariables(type, map); - - final Class<?> superClass = clazz.getSuperclass(); - final Type superClassType = clazz.getGenericSuperclass(); - if (superClass != null) { - gatherTypeVariables(superClass, superClassType, map); - } - - final Class<?>[] interfaces = clazz.getInterfaces(); - final Type[] interfaceTypes = clazz.getGenericInterfaces(); - for (int i = 0; i < interfaces.length; ++i) { - gatherTypeVariables(interfaces[i], interfaceTypes[i], map); - } - } - - /** - * パラメータ化された型(クラスまたはインタフェース)が持つ型変数および型引数を集めて<code>map</code>に追加する。 - * - * @param type 型 - * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} - */ - protected static void gatherTypeVariables(final Type type, final Map<TypeVariable<?>, Type> map) { - if (ParameterizedType.class.isInstance(type)) { - final ParameterizedType parameterizedType = ParameterizedType.class.cast(type); - final TypeVariable<?>[] typeVariables = - GenericDeclaration.class.cast(parameterizedType.getRawType()).getTypeParameters(); - final Type[] actualTypes = parameterizedType.getActualTypeArguments(); - for (int i = 0; i < actualTypes.length; ++i) { - map.put(typeVariables[i], actualTypes[i]); - } - } - } - - /** - * <code>type</code>の実際の型を取得する。 - * <ul> - * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> - * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> - * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> - * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> - * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> - * <li>その他の場合は<code>null</code>を返す。</li> - * </ul> - * - * @param type タイプ - * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} - * @return <code>type</code>の実際の型 - */ - public static Class<?> getActualClass(final Type type, final Map<TypeVariable<?>, Type> map) { - if (Class.class.isInstance(type)) { - return Class.class.cast(type); - } - if (ParameterizedType.class.isInstance(type)) { - return getActualClass(ParameterizedType.class.cast(type).getRawType(), map); - } - if (WildcardType.class.isInstance(type)) { - return getActualClass(WildcardType.class.cast(type).getUpperBounds()[0], map); - } - if (TypeVariable.class.isInstance(type)) { - return getActualClass(map.get(TypeVariable.class.cast(type)), map); - } - if (GenericArrayType.class.isInstance(type)) { - final GenericArrayType genericArrayType = GenericArrayType.class.cast(type); - final Class<?> componentClass = getActualClass(genericArrayType.getGenericComponentType(), map); - return Array.newInstance(componentClass, 0).getClass(); - } - return null; - } - - /** - * パラメータ化された型を要素とする配列の実際の要素型を取得する。 - * <ul> - * <li><code>type</code>がパラメータ化された型の配列でない場合は<code>null</code>を取得する。</li> - * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> - * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> - * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> - * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> - * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> - * <li>その他の場合は<code>null</code>を返す。</li> - * </ul> - * - * @param type パラメータ化された型を要素とする配列 - * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} - * @return パラメータ化された型を要素とする配列の実際の要素型 - */ - public static Class<?> getActualElementClassOfArray(final Type type, final Map<TypeVariable<?>, Type> map) { - if (!GenericArrayType.class.isInstance(type)) { - return null; - } - return getActualClass(GenericArrayType.class.cast(type).getGenericComponentType(), map); - } - - /** - * パラメータ化された{@link Collection}の実際の要素型を返す。 - * <ul> - * <li><code>type</code>がパラメータ化された{@link Collection}でない場合は<code>null</code> - * を返す。</li> - * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> - * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> - * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> - * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> - * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> - * <li>その他の場合は<code>null</code>を返す。</li> - * </ul> - * - * @param type パラメータ化された{@link Collection} - * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} - * @return パラメータ化された{@link Collection}の実際の要素型 - */ - public static Class<?> getActualElementClassOfCollection(final Type type, final Map<TypeVariable<?>, Type> map) { - if (!isTypeOf(type, Collection.class)) { - return null; - } - return getActualClass(getGenericParameter(type, 0), map); - } - - /** - * パラメータ化された{@link List}の実際の要素型を取得する。 - * <ul> - * <li><code>type</code>がパラメータ化された{@link List}でない場合は<code>null</code>を返す。</li> - * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> - * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> - * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> - * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> - * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> - * <li>その他の場合は<code>null</code>を返す。</li> - * </ul> - * - * @param type パラメータ化された{@link List} - * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} - * @return パラメータ化された{@link List}の実際の要素型 - */ - public static Class<?> getActualElementClassOfList(final Type type, final Map<TypeVariable<?>, Type> map) { - if (!isTypeOf(type, List.class)) { - return null; - } - return getActualClass(getGenericParameter(type, 0), map); - } - - /** - * パラメータ化された{@link Set}の実際の要素型を取得する。 - * <ul> - * <li><code>type</code>がパラメータ化された{@link Set}でない場合は<code>null</code>を返す。</li> - * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> - * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> - * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> - * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> - * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> - * <li>その他の場合は<code>null</code>を返す。</li> - * </ul> - * - * @param type パラメータ化された{@link Set} - * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} - * @return パラメータ化された{@link Set}の実際の要素型 - */ - public static Class<?> getActualElementClassOfSet(final Type type, final Map<TypeVariable<?>, Type> map) { - if (!isTypeOf(type, Set.class)) { - return null; - } - return getActualClass(getGenericParameter(type, 0), map); - } - - /** - * パラメータ化された{@link Map}のキーの実際の型を取得する。 - * <ul> - * <li>キー型がパラメータ化された{@link Map}でない場合は<code>null</code>を返す。</li> - * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> - * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> - * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> - * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> - * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> - * <li>その他の場合は<code>null</code>を返す。</li> - * </ul> - * - * @param type パラメータ化された{@link Map} - * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} - * @return パラメータ化された{@link Map}のキーの実際の型 - */ - public static Class<?> getActualKeyClassOfMap(final Type type, final Map<TypeVariable<?>, Type> map) { - if (!isTypeOf(type, Map.class)) { - return null; - } - return getActualClass(getGenericParameter(type, 0), map); - } - - /** - * パラメータ化された{@link Map}の値の実際の型を取得する。 - * <ul> - * <li><code>type</code>がパラメータ化された{@link Map}でない場合は<code>null</code>を返す。</li> - * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> - * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> - * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> - * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> - * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> - * <li>その他の場合は<code>null</code>を返す。</li> - * </ul> - * - * @param type パラメータ化された{@link Map} - * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} - * @return パラメータ化された{@link Map}の値の実際の型 - */ - public static Class<?> getActualValueClassOfMap(final Type type, final Map<TypeVariable<?>, Type> map) { - if (!isTypeOf(type, Map.class)) { - return null; - } - return getActualClass(getGenericParameter(type, 1), map); - } - - /** - * パラメータ化された型を要素とする配列の要素型を取得する。 - * <p> - * <code>type</code>がパラメータ化された型の配列でない場合は<code>null</code>を返す。 - * </p> - * - * @param type パラメータ化された型を要素とする配列 - * @return パラメータ化された型を要素とする配列の要素型 - */ - public static Type getElementTypeOfArray(final Type type) { - if (!GenericArrayType.class.isInstance(type)) { - return null; - } - return GenericArrayType.class.cast(type).getGenericComponentType(); - } - - /** - * パラメータ化された{@link Collection}の要素型を取得する。 - * <p> - * <code>type</code>がパラメータ化された{@link List}でない場合は<code>null</code>を返す。 - * </p> - * - * @param type パラメータ化された{@link List} - * @return パラメータ化された{@link List}の要素型 - */ - public static Type getElementTypeOfCollection(final Type type) { - if (!isTypeOf(type, Collection.class)) { - return null; - } - return getGenericParameter(type, 0); - } - - /** - * パラメータ化された{@link List}の要素型を取得する。 - * <p> - * <code>type</code>がパラメータ化された{@link List}でない場合は<code>null</code>を返す。 - * </p> - * - * @param type パラメータ化された{@link List} - * @return パラメータ化された{@link List}の要素型 - */ - public static Type getElementTypeOfList(final Type type) { - if (!isTypeOf(type, List.class)) { - return null; - } - return getGenericParameter(type, 0); - } - - /** - * パラメータ化された{@link Set}の要素型を取得する。 - * <p> - * <code>type</code>がパラメータ化された{@link Set}でない場合は<code>null</code>を返す。 - * </p> - * - * @param type パラメータ化された{@link Set} - * @return パラメータ化された{@link Set}の要素型 - */ - public static Type getElementTypeOfSet(final Type type) { - if (!isTypeOf(type, Set.class)) { - return null; - } - return getGenericParameter(type, 0); - } - - /** - * <code>type</code>の型引数の配列を取得する。 - * <p> - * <code>type</code>がパラメータ化された型でない場合は<code>null</code>を返す。 - * </p> - * - * @param type タイプ - * @return <code>type</code>の型引数の配列 - */ - public static Type[] getGenericParameter(final Type type) { - if (ParameterizedType.class.isInstance(type)) { - return ParameterizedType.class.cast(type).getActualTypeArguments(); - } - if (GenericArrayType.class.isInstance(type)) { - return getGenericParameter(GenericArrayType.class.cast(type).getGenericComponentType()); - } - return new Type[0]; - } - - /** - * 指定された位置の<code>type</code>の型引数を取得する。 - * <p> - * <code>type</code>がパラメータ化された型でない場合は<code>null</code>を返す。 - * </p> - * - * @param type タイプ - * @param index 位置 - * @return 指定された位置の<code>type</code>の型引数 - */ - public static Type getGenericParameter(final Type type, final int index) { - if (!ParameterizedType.class.isInstance(type)) { - return null; - } - final Type[] genericParameter = getGenericParameter(type); - if (genericParameter == null) { - return null; - } - return genericParameter[index]; - } - - /** - * パラメータ化された{@link Map}のキーの型を取得する。 - * <p> - * <code>type</code>がパラメータ化された{@link Map}でない場合は<code>null</code>を返す。 - * </p> - * - * @param type パラメータ化された{@link Map} - * @return パラメータ化された{@link Map}のキーの型 - */ - public static Type getKeyTypeOfMap(final Type type) { - if (!isTypeOf(type, Map.class)) { - return null; - } - return getGenericParameter(type, 0); - } - - /** - * <code>type</code>の原型を取得する。 - * <ul> - * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> - * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> - * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> - * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> - * <li>その他の場合は<code>null</code>を返す。</li> - * </ul> - * - * @param type タイプ - * @return <code>type</code>の原型 - */ - public static Class<?> getRawClass(final Type type) { - if (Class.class.isInstance(type)) { - return Class.class.cast(type); - } - if (ParameterizedType.class.isInstance(type)) { - final ParameterizedType parameterizedType = ParameterizedType.class.cast(type); - return getRawClass(parameterizedType.getRawType()); - } - if (WildcardType.class.isInstance(type)) { - final WildcardType wildcardType = WildcardType.class.cast(type); - final Type[] types = wildcardType.getUpperBounds(); - return getRawClass(types[0]); - } - if (GenericArrayType.class.isInstance(type)) { - final GenericArrayType genericArrayType = GenericArrayType.class.cast(type); - final Class<?> rawClass = getRawClass(genericArrayType.getGenericComponentType()); - return Array.newInstance(rawClass, 0).getClass(); - } - return null; - } - - /** - * パラメータ化された型(クラスまたはインタフェース)が持つ型変数をキー、型引数を値とする{@link Map}を取得する。 - * - * @param clazz パラメータ化された型(クラスまたはインタフェース) - * @return パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} - */ - public static Map<TypeVariable<?>, Type> getTypeVariableMap(final Class<?> clazz) { - final Map<TypeVariable<?>, Type> map = CollectionsUtil.newLinkedHashMap(); - - final Class<?> superClass = clazz.getSuperclass(); - final Type superClassType = clazz.getGenericSuperclass(); - if (superClass != null) { - gatherTypeVariables(superClass, superClassType, map); - } - - final Class<?>[] interfaces = clazz.getInterfaces(); - final Type[] interfaceTypes = clazz.getGenericInterfaces(); - for (int i = 0; i < interfaces.length; ++i) { - gatherTypeVariables(interfaces[i], interfaceTypes[i], map); - } - - return map; - } - - /** - * パラメータ化された{@link Map}の値の型を取得する。 - * <p> - * <code>type</code>がパラメータ化された{@link Map}でない場合は<code>null</code>を返す。 - * </p> - * - * @param type パラメータ化された{@link Map} - * @return パラメータ化された{@link Map}の値の型 - */ - public static Type getValueTypeOfMap(final Type type) { - if (!isTypeOf(type, Map.class)) { - return null; - } - return getGenericParameter(type, 1); - } - - /** - * <code>type</code>の原型が<code>clazz</code>に代入可能であれば<code>true</code>を、 - * それ以外の場合は<code>false</code>を取得する。 - * - * @param type タイプ - * @param clazz クラス - * @return <code>type</code>の原型が<code>clazz</code>に代入可能であれば<code>true</code> - */ - public static boolean isTypeOf(final Type type, final Class<?> clazz) { - if (Class.class.isInstance(type)) { - return clazz.isAssignableFrom(Class.class.cast(type)); - } - if (ParameterizedType.class.isInstance(type)) { - final ParameterizedType parameterizedType = ParameterizedType.class.cast(type); - return isTypeOf(parameterizedType.getRawType(), clazz); - } - return false; - } - - private GenericUtil() { - throw new JiemamyError("不到達ポイント"); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.lang.reflect.Array; +import java.lang.reflect.GenericArrayType; +import java.lang.reflect.GenericDeclaration; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.lang.reflect.WildcardType; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.jiemamy.exception.JiemamyError; + +/** + * Genericsを扱うためのユーティリティ・クラス。 + * + * @author j5ik2o + */ +public abstract class GenericUtil { + + /** + * パラメータ化された型(クラスまたはインタフェース)が持つ型変数および型引数を集めて<code>map</code>に追加する。 + * + * @param clazz クラス + * @param type 型 + * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} + */ + protected static void gatherTypeVariables(final Class<?> clazz, final Type type, + final Map<TypeVariable<?>, Type> map) { + if (clazz == null) { + return; + } + gatherTypeVariables(type, map); + + final Class<?> superClass = clazz.getSuperclass(); + final Type superClassType = clazz.getGenericSuperclass(); + if (superClass != null) { + gatherTypeVariables(superClass, superClassType, map); + } + + final Class<?>[] interfaces = clazz.getInterfaces(); + final Type[] interfaceTypes = clazz.getGenericInterfaces(); + for (int i = 0; i < interfaces.length; ++i) { + gatherTypeVariables(interfaces[i], interfaceTypes[i], map); + } + } + + /** + * パラメータ化された型(クラスまたはインタフェース)が持つ型変数および型引数を集めて<code>map</code>に追加する。 + * + * @param type 型 + * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} + */ + protected static void gatherTypeVariables(final Type type, final Map<TypeVariable<?>, Type> map) { + if (ParameterizedType.class.isInstance(type)) { + final ParameterizedType parameterizedType = ParameterizedType.class.cast(type); + final TypeVariable<?>[] typeVariables = + GenericDeclaration.class.cast(parameterizedType.getRawType()).getTypeParameters(); + final Type[] actualTypes = parameterizedType.getActualTypeArguments(); + for (int i = 0; i < actualTypes.length; ++i) { + map.put(typeVariables[i], actualTypes[i]); + } + } + } + + /** + * <code>type</code>の実際の型を取得する。 + * <ul> + * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> + * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> + * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> + * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> + * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> + * <li>その他の場合は<code>null</code>を返す。</li> + * </ul> + * + * @param type タイプ + * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} + * @return <code>type</code>の実際の型 + */ + public static Class<?> getActualClass(final Type type, final Map<TypeVariable<?>, Type> map) { + if (Class.class.isInstance(type)) { + return Class.class.cast(type); + } + if (ParameterizedType.class.isInstance(type)) { + return getActualClass(ParameterizedType.class.cast(type).getRawType(), map); + } + if (WildcardType.class.isInstance(type)) { + return getActualClass(WildcardType.class.cast(type).getUpperBounds()[0], map); + } + if (TypeVariable.class.isInstance(type)) { + return getActualClass(map.get(TypeVariable.class.cast(type)), map); + } + if (GenericArrayType.class.isInstance(type)) { + final GenericArrayType genericArrayType = GenericArrayType.class.cast(type); + final Class<?> componentClass = getActualClass(genericArrayType.getGenericComponentType(), map); + return Array.newInstance(componentClass, 0).getClass(); + } + return null; + } + + /** + * パラメータ化された型を要素とする配列の実際の要素型を取得する。 + * <ul> + * <li><code>type</code>がパラメータ化された型の配列でない場合は<code>null</code>を取得する。</li> + * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> + * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> + * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> + * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> + * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> + * <li>その他の場合は<code>null</code>を返す。</li> + * </ul> + * + * @param type パラメータ化された型を要素とする配列 + * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} + * @return パラメータ化された型を要素とする配列の実際の要素型 + */ + public static Class<?> getActualElementClassOfArray(final Type type, final Map<TypeVariable<?>, Type> map) { + if (!GenericArrayType.class.isInstance(type)) { + return null; + } + return getActualClass(GenericArrayType.class.cast(type).getGenericComponentType(), map); + } + + /** + * パラメータ化された{@link Collection}の実際の要素型を返す。 + * <ul> + * <li><code>type</code>がパラメータ化された{@link Collection}でない場合は<code>null</code> + * を返す。</li> + * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> + * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> + * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> + * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> + * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> + * <li>その他の場合は<code>null</code>を返す。</li> + * </ul> + * + * @param type パラメータ化された{@link Collection} + * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} + * @return パラメータ化された{@link Collection}の実際の要素型 + */ + public static Class<?> getActualElementClassOfCollection(final Type type, final Map<TypeVariable<?>, Type> map) { + if (!isTypeOf(type, Collection.class)) { + return null; + } + return getActualClass(getGenericParameter(type, 0), map); + } + + /** + * パラメータ化された{@link List}の実際の要素型を取得する。 + * <ul> + * <li><code>type</code>がパラメータ化された{@link List}でない場合は<code>null</code>を返す。</li> + * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> + * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> + * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> + * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> + * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> + * <li>その他の場合は<code>null</code>を返す。</li> + * </ul> + * + * @param type パラメータ化された{@link List} + * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} + * @return パラメータ化された{@link List}の実際の要素型 + */ + public static Class<?> getActualElementClassOfList(final Type type, final Map<TypeVariable<?>, Type> map) { + if (!isTypeOf(type, List.class)) { + return null; + } + return getActualClass(getGenericParameter(type, 0), map); + } + + /** + * パラメータ化された{@link Set}の実際の要素型を取得する。 + * <ul> + * <li><code>type</code>がパラメータ化された{@link Set}でない場合は<code>null</code>を返す。</li> + * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> + * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> + * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> + * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> + * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> + * <li>その他の場合は<code>null</code>を返す。</li> + * </ul> + * + * @param type パラメータ化された{@link Set} + * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} + * @return パラメータ化された{@link Set}の実際の要素型 + */ + public static Class<?> getActualElementClassOfSet(final Type type, final Map<TypeVariable<?>, Type> map) { + if (!isTypeOf(type, Set.class)) { + return null; + } + return getActualClass(getGenericParameter(type, 0), map); + } + + /** + * パラメータ化された{@link Map}のキーの実際の型を取得する。 + * <ul> + * <li>キー型がパラメータ化された{@link Map}でない場合は<code>null</code>を返す。</li> + * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> + * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> + * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> + * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> + * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> + * <li>その他の場合は<code>null</code>を返す。</li> + * </ul> + * + * @param type パラメータ化された{@link Map} + * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} + * @return パラメータ化された{@link Map}のキーの実際の型 + */ + public static Class<?> getActualKeyClassOfMap(final Type type, final Map<TypeVariable<?>, Type> map) { + if (!isTypeOf(type, Map.class)) { + return null; + } + return getActualClass(getGenericParameter(type, 0), map); + } + + /** + * パラメータ化された{@link Map}の値の実際の型を取得する。 + * <ul> + * <li><code>type</code>がパラメータ化された{@link Map}でない場合は<code>null</code>を返す。</li> + * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> + * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> + * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> + * <li><code>type</code>が型変数の場合はその変数の実際の型引数を返す。</li> + * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> + * <li>その他の場合は<code>null</code>を返す。</li> + * </ul> + * + * @param type パラメータ化された{@link Map} + * @param map パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} + * @return パラメータ化された{@link Map}の値の実際の型 + */ + public static Class<?> getActualValueClassOfMap(final Type type, final Map<TypeVariable<?>, Type> map) { + if (!isTypeOf(type, Map.class)) { + return null; + } + return getActualClass(getGenericParameter(type, 1), map); + } + + /** + * パラメータ化された型を要素とする配列の要素型を取得する。 + * <p> + * <code>type</code>がパラメータ化された型の配列でない場合は<code>null</code>を返す。 + * </p> + * + * @param type パラメータ化された型を要素とする配列 + * @return パラメータ化された型を要素とする配列の要素型 + */ + public static Type getElementTypeOfArray(final Type type) { + if (!GenericArrayType.class.isInstance(type)) { + return null; + } + return GenericArrayType.class.cast(type).getGenericComponentType(); + } + + /** + * パラメータ化された{@link Collection}の要素型を取得する。 + * <p> + * <code>type</code>がパラメータ化された{@link List}でない場合は<code>null</code>を返す。 + * </p> + * + * @param type パラメータ化された{@link List} + * @return パラメータ化された{@link List}の要素型 + */ + public static Type getElementTypeOfCollection(final Type type) { + if (!isTypeOf(type, Collection.class)) { + return null; + } + return getGenericParameter(type, 0); + } + + /** + * パラメータ化された{@link List}の要素型を取得する。 + * <p> + * <code>type</code>がパラメータ化された{@link List}でない場合は<code>null</code>を返す。 + * </p> + * + * @param type パラメータ化された{@link List} + * @return パラメータ化された{@link List}の要素型 + */ + public static Type getElementTypeOfList(final Type type) { + if (!isTypeOf(type, List.class)) { + return null; + } + return getGenericParameter(type, 0); + } + + /** + * パラメータ化された{@link Set}の要素型を取得する。 + * <p> + * <code>type</code>がパラメータ化された{@link Set}でない場合は<code>null</code>を返す。 + * </p> + * + * @param type パラメータ化された{@link Set} + * @return パラメータ化された{@link Set}の要素型 + */ + public static Type getElementTypeOfSet(final Type type) { + if (!isTypeOf(type, Set.class)) { + return null; + } + return getGenericParameter(type, 0); + } + + /** + * <code>type</code>の型引数の配列を取得する。 + * <p> + * <code>type</code>がパラメータ化された型でない場合は<code>null</code>を返す。 + * </p> + * + * @param type タイプ + * @return <code>type</code>の型引数の配列 + */ + public static Type[] getGenericParameter(final Type type) { + if (ParameterizedType.class.isInstance(type)) { + return ParameterizedType.class.cast(type).getActualTypeArguments(); + } + if (GenericArrayType.class.isInstance(type)) { + return getGenericParameter(GenericArrayType.class.cast(type).getGenericComponentType()); + } + return new Type[0]; + } + + /** + * 指定された位置の<code>type</code>の型引数を取得する。 + * <p> + * <code>type</code>がパラメータ化された型でない場合は<code>null</code>を返す。 + * </p> + * + * @param type タイプ + * @param index 位置 + * @return 指定された位置の<code>type</code>の型引数 + */ + public static Type getGenericParameter(final Type type, final int index) { + if (!ParameterizedType.class.isInstance(type)) { + return null; + } + final Type[] genericParameter = getGenericParameter(type); + if (genericParameter == null) { + return null; + } + return genericParameter[index]; + } + + /** + * パラメータ化された{@link Map}のキーの型を取得する。 + * <p> + * <code>type</code>がパラメータ化された{@link Map}でない場合は<code>null</code>を返す。 + * </p> + * + * @param type パラメータ化された{@link Map} + * @return パラメータ化された{@link Map}のキーの型 + */ + public static Type getKeyTypeOfMap(final Type type) { + if (!isTypeOf(type, Map.class)) { + return null; + } + return getGenericParameter(type, 0); + } + + /** + * <code>type</code>の原型を取得する。 + * <ul> + * <li><code>type</code>が<code>Class</code>の場合はそのまま返す。</li> + * <li><code>type</code>がパラメータ化された型の場合はその原型を返す。</li> + * <li><code>type</code>がワイルドカード型の場合は(最初の)上限境界を返す。</li> + * <li><code>type</code>が配列の場合はその要素の実際の型の配列を返す。</li> + * <li>その他の場合は<code>null</code>を返す。</li> + * </ul> + * + * @param type タイプ + * @return <code>type</code>の原型 + */ + public static Class<?> getRawClass(final Type type) { + if (Class.class.isInstance(type)) { + return Class.class.cast(type); + } + if (ParameterizedType.class.isInstance(type)) { + final ParameterizedType parameterizedType = ParameterizedType.class.cast(type); + return getRawClass(parameterizedType.getRawType()); + } + if (WildcardType.class.isInstance(type)) { + final WildcardType wildcardType = WildcardType.class.cast(type); + final Type[] types = wildcardType.getUpperBounds(); + return getRawClass(types[0]); + } + if (GenericArrayType.class.isInstance(type)) { + final GenericArrayType genericArrayType = GenericArrayType.class.cast(type); + final Class<?> rawClass = getRawClass(genericArrayType.getGenericComponentType()); + return Array.newInstance(rawClass, 0).getClass(); + } + return null; + } + + /** + * パラメータ化された型(クラスまたはインタフェース)が持つ型変数をキー、型引数を値とする{@link Map}を取得する。 + * + * @param clazz パラメータ化された型(クラスまたはインタフェース) + * @return パラメータ化された型が持つ型変数をキー、型引数を値とする{@link Map} + */ + public static Map<TypeVariable<?>, Type> getTypeVariableMap(final Class<?> clazz) { + final Map<TypeVariable<?>, Type> map = CollectionsUtil.newLinkedHashMap(); + + final Class<?> superClass = clazz.getSuperclass(); + final Type superClassType = clazz.getGenericSuperclass(); + if (superClass != null) { + gatherTypeVariables(superClass, superClassType, map); + } + + final Class<?>[] interfaces = clazz.getInterfaces(); + final Type[] interfaceTypes = clazz.getGenericInterfaces(); + for (int i = 0; i < interfaces.length; ++i) { + gatherTypeVariables(interfaces[i], interfaceTypes[i], map); + } + + return map; + } + + /** + * パラメータ化された{@link Map}の値の型を取得する。 + * <p> + * <code>type</code>がパラメータ化された{@link Map}でない場合は<code>null</code>を返す。 + * </p> + * + * @param type パラメータ化された{@link Map} + * @return パラメータ化された{@link Map}の値の型 + */ + public static Type getValueTypeOfMap(final Type type) { + if (!isTypeOf(type, Map.class)) { + return null; + } + return getGenericParameter(type, 1); + } + + /** + * <code>type</code>の原型が<code>clazz</code>に代入可能であれば<code>true</code>を、 + * それ以外の場合は<code>false</code>を取得する。 + * + * @param type タイプ + * @param clazz クラス + * @return <code>type</code>の原型が<code>clazz</code>に代入可能であれば<code>true</code> + */ + public static boolean isTypeOf(final Type type, final Class<?> clazz) { + if (Class.class.isInstance(type)) { + return clazz.isAssignableFrom(Class.class.cast(type)); + } + if (ParameterizedType.class.isInstance(type)) { + final ParameterizedType parameterizedType = ParameterizedType.class.cast(type); + return isTypeOf(parameterizedType.getRawType(), clazz); + } + return false; + } + + private GenericUtil() { + throw new JiemamyError("不到達ポイント"); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/GenericUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/InputStreamUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/InputStreamUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/InputStreamUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,106 +1,106 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link InputStream}用のユーティリティクラス。 - * - * @author j5ik2o - * - */ -public class InputStreamUtil { - - /** バッファサイズ */ - private static final int BUFF_SIZE = 8192; - - - /** - * {@link InputStream#available()}の例外処理をラップしたメソッド。 - * - * @param is {@link InputStream} - * @return 可能なサイズ - * @throws IOException 入出力が失敗した場合 - */ - public static int available(InputStream is) throws IOException { - return is.available(); - } - - /** - * {@link InputStream}を閉じる。 - * - * @param is {@link InputStream} - * @throws IOException 入出力が失敗した場合 - * @see InputStream#close() - */ - public static void close(InputStream is) throws IOException { - if (is == null) { - return; - } - is.close(); - } - - /** - * {@link InputStream}の内容を {@link OutputStream}にコピーします。 - * - * @param is {@link InputStream} - * @param os {@link OutputStream} - * @throws IOException 入出力が失敗した場合 - */ - public static final void copy(InputStream is, OutputStream os) throws IOException { - byte[] buf = new byte[BUFF_SIZE]; - int n = 0; - while ((n = is.read(buf, 0, buf.length)) != -1) { - os.write(buf, 0, n); - } - } - - /** - * {@link InputStream}からbyteの配列を取得する。 - * - * @param is {@link InputStream} - * @return byteの配列 - * @throws IOException 入出力が失敗した場合 - */ - public static final byte[] getBytes(InputStream is) throws IOException { - byte[] buf = new byte[BUFF_SIZE]; - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - int n = 0; - while ((n = is.read(buf, 0, buf.length)) != -1) { - baos.write(buf, 0, n); - } - byte[] bytes = baos.toByteArray(); - return bytes; - } finally { - //if (is != null) { - close(is); - //} - } - } - - private InputStreamUtil() { - throw new JiemamyError("不到達ポイント"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link InputStream}用のユーティリティクラス。 + * + * @author j5ik2o + * + */ +public class InputStreamUtil { + + /** バッファサイズ */ + private static final int BUFF_SIZE = 8192; + + + /** + * {@link InputStream#available()}の例外処理をラップしたメソッド。 + * + * @param is {@link InputStream} + * @return 可能なサイズ + * @throws IOException 入出力が失敗した場合 + */ + public static int available(InputStream is) throws IOException { + return is.available(); + } + + /** + * {@link InputStream}を閉じる。 + * + * @param is {@link InputStream} + * @throws IOException 入出力が失敗した場合 + * @see InputStream#close() + */ + public static void close(InputStream is) throws IOException { + if (is == null) { + return; + } + is.close(); + } + + /** + * {@link InputStream}の内容を {@link OutputStream}にコピーします。 + * + * @param is {@link InputStream} + * @param os {@link OutputStream} + * @throws IOException 入出力が失敗した場合 + */ + public static final void copy(InputStream is, OutputStream os) throws IOException { + byte[] buf = new byte[BUFF_SIZE]; + int n = 0; + while ((n = is.read(buf, 0, buf.length)) != -1) { + os.write(buf, 0, n); + } + } + + /** + * {@link InputStream}からbyteの配列を取得する。 + * + * @param is {@link InputStream} + * @return byteの配列 + * @throws IOException 入出力が失敗した場合 + */ + public static final byte[] getBytes(InputStream is) throws IOException { + byte[] buf = new byte[BUFF_SIZE]; + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + int n = 0; + while ((n = is.read(buf, 0, buf.length)) != -1) { + baos.write(buf, 0, n); + } + byte[] bytes = baos.toByteArray(); + return bytes; + } finally { + //if (is != null) { + close(is); + //} + } + } + + private InputStreamUtil() { + throw new JiemamyError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/InputStreamUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/IterableNodeList.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/IterableNodeList.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/IterableNodeList.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,88 +1,88 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/28 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.Iterator; - -import org.apache.commons.lang.Validate; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * {@link NodeList}の{@link Iterable}ラッパー。 - * - * @author daisuke - */ -public class IterableNodeList implements Iterable<Node> { - - private final NodeList nodeList; - - - /** - * インスタンスを生成する。 - * - * @param nodeList ノードリスト - */ - public IterableNodeList(NodeList nodeList) { - Validate.notNull(nodeList); - this.nodeList = nodeList; - } - - public Iterator<Node> iterator() { - return new NodeListIterator(nodeList); - } - - - /** - * {@link NodeList}の{@link Iterator}ラッパー。 - * - * @author daisuke - */ - public class NodeListIterator implements Iterator<Node> { - - private final NodeList nodeList; - - private int index; - - - /** - * インスタンスを生成する。 - * - * @param nodeList ノードリスト - */ - public NodeListIterator(NodeList nodeList) { - Validate.notNull(nodeList); - this.nodeList = nodeList; - } - - public boolean hasNext() { - return nodeList.getLength() > index; - } - - public Node next() { - return nodeList.item(index++); - } - - public void remove() { - throw new UnsupportedOperationException(); - } - - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/28 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.Iterator; + +import org.apache.commons.lang.Validate; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * {@link NodeList}の{@link Iterable}ラッパー。 + * + * @author daisuke + */ +public class IterableNodeList implements Iterable<Node> { + + private final NodeList nodeList; + + + /** + * インスタンスを生成する。 + * + * @param nodeList ノードリスト + */ + public IterableNodeList(NodeList nodeList) { + Validate.notNull(nodeList); + this.nodeList = nodeList; + } + + public Iterator<Node> iterator() { + return new NodeListIterator(nodeList); + } + + + /** + * {@link NodeList}の{@link Iterator}ラッパー。 + * + * @author daisuke + */ + public class NodeListIterator implements Iterator<Node> { + + private final NodeList nodeList; + + private int index; + + + /** + * インスタンスを生成する。 + * + * @param nodeList ノードリスト + */ + public NodeListIterator(NodeList nodeList) { + Validate.notNull(nodeList); + this.nodeList = nodeList; + } + + public boolean hasNext() { + return nodeList.getLength() > index; + } + + public Node next() { + return nodeList.item(index++); + } + + public void remove() { + throw new UnsupportedOperationException(); + } + + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/IterableNodeList.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarFileUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarFileUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarFileUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,117 +1,117 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.JarURLConnection; -import java.net.URL; -import java.net.URLConnection; -import java.util.jar.JarFile; -import java.util.zip.ZipEntry; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link JarFile}を扱うユーティリティクラス。 - * - * @author j5ik2o - */ -public class JarFileUtil { - - /** - * Jarファイルを閉じる。 - * - * @param jarFile Jarファイル - * @throws IOException 入出力が失敗した場合 - */ - public static void close(final JarFile jarFile) throws IOException { - jarFile.close(); - } - - /** - * 指定されたJarファイルを読み取るための<code>JarFile</code>を作成する。 - * - * @param file ファイル - * @return 指定されたJarファイルを読み取るための<code>JarFile</code> - * @throws IOException 入出力が失敗した場合 - */ - public static JarFile create(final File file) throws IOException { - return new JarFile(file); - } - - /** - * 指定されたJarファイルを読み取るための<code>JarFile</code>を作成する。 - * - * @param file ファイルパス - * @return 指定されたJarファイルを読み取るための<code>JarFile</code> - * @throws IOException 入出力が失敗した場合 - */ - public static JarFile create(final String file) throws IOException { - return new JarFile(file); - } - - /** - * 指定されたJarファイルエントリの内容を読み込むための入力ストリームを取得する。 - * - * @param file Jarファイル - * @param entry Jarファイルエントリ - * @return 指定されたJarファイルエントリの内容を読み込むための入力ストリーム - * @throws IOException 入出力が失敗した場合 - */ - public static InputStream getInputStream(final JarFile file, final ZipEntry entry) throws IOException { - return file.getInputStream(entry); - } - - /** - * URLで指定されたJarファイルを読み取るための<code>JarFile</code>を作成する。 - * - * @param jarUrl Jarファイルを示すURL - * @return 指定されたJarファイルを読み取るための<code>JarFile</code> - * @throws IOException 入出力エラーが発生した場合 - */ - public static JarFile toJarFile(final URL jarUrl) throws IOException { - final URLConnection con = URLUtil.openConnection(jarUrl); - if (con instanceof JarURLConnection) { - return JarURLConnectionUtil.getJarFile((JarURLConnection) con); - } - return create(new File(toJarFilePath(jarUrl))); - } - - /** - * URLで指定されたJarファイルのパスを返します。 - * - * @param jarUrl Jarファイルを示すURL - * @return URLで指定されたJarファイルのパス - * @throws IOException 入出力が失敗した場合 - */ - public static String toJarFilePath(final URL jarUrl) throws IOException { - final URL nestedUrl = URLUtil.create(jarUrl.getPath()); - final String nestedUrlPath = nestedUrl.getPath(); - final int pos = nestedUrlPath.lastIndexOf('!'); - final String jarFilePath = nestedUrlPath.substring(0, pos); - final File jarFile = new File(URLUtil.decode(jarFilePath, "UTF8")); - return FileUtil.getCanonicalPath(jarFile); - } - - private JarFileUtil() { - throw new JiemamyError("不到達ポイント"); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.JarURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link JarFile}を扱うユーティリティクラス。 + * + * @author j5ik2o + */ +public class JarFileUtil { + + /** + * Jarファイルを閉じる。 + * + * @param jarFile Jarファイル + * @throws IOException 入出力が失敗した場合 + */ + public static void close(final JarFile jarFile) throws IOException { + jarFile.close(); + } + + /** + * 指定されたJarファイルを読み取るための<code>JarFile</code>を作成する。 + * + * @param file ファイル + * @return 指定されたJarファイルを読み取るための<code>JarFile</code> + * @throws IOException 入出力が失敗した場合 + */ + public static JarFile create(final File file) throws IOException { + return new JarFile(file); + } + + /** + * 指定されたJarファイルを読み取るための<code>JarFile</code>を作成する。 + * + * @param file ファイルパス + * @return 指定されたJarファイルを読み取るための<code>JarFile</code> + * @throws IOException 入出力が失敗した場合 + */ + public static JarFile create(final String file) throws IOException { + return new JarFile(file); + } + + /** + * 指定されたJarファイルエントリの内容を読み込むための入力ストリームを取得する。 + * + * @param file Jarファイル + * @param entry Jarファイルエントリ + * @return 指定されたJarファイルエントリの内容を読み込むための入力ストリーム + * @throws IOException 入出力が失敗した場合 + */ + public static InputStream getInputStream(final JarFile file, final ZipEntry entry) throws IOException { + return file.getInputStream(entry); + } + + /** + * URLで指定されたJarファイルを読み取るための<code>JarFile</code>を作成する。 + * + * @param jarUrl Jarファイルを示すURL + * @return 指定されたJarファイルを読み取るための<code>JarFile</code> + * @throws IOException 入出力エラーが発生した場合 + */ + public static JarFile toJarFile(final URL jarUrl) throws IOException { + final URLConnection con = URLUtil.openConnection(jarUrl); + if (con instanceof JarURLConnection) { + return JarURLConnectionUtil.getJarFile((JarURLConnection) con); + } + return create(new File(toJarFilePath(jarUrl))); + } + + /** + * URLで指定されたJarファイルのパスを返します。 + * + * @param jarUrl Jarファイルを示すURL + * @return URLで指定されたJarファイルのパス + * @throws IOException 入出力が失敗した場合 + */ + public static String toJarFilePath(final URL jarUrl) throws IOException { + final URL nestedUrl = URLUtil.create(jarUrl.getPath()); + final String nestedUrlPath = nestedUrl.getPath(); + final int pos = nestedUrlPath.lastIndexOf('!'); + final String jarFilePath = nestedUrlPath.substring(0, pos); + final File jarFile = new File(URLUtil.decode(jarFilePath, "UTF8")); + return FileUtil.getCanonicalPath(jarFile); + } + + private JarFileUtil() { + throw new JiemamyError("不到達ポイント"); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarFileUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarInputStreamUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarInputStreamUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarInputStreamUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,61 +1,61 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.IOException; -import java.io.InputStream; -import java.util.jar.JarEntry; -import java.util.jar.JarInputStream; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link JarInputStream}用のユーティリティクラス。 - * - * @author j5ik2o - */ -public class JarInputStreamUtil { - - /** - * {@link JarInputStream}を作成する。 - * - * @param is {@link InputStream} - * @return {@link JarInputStream} - * @throws IOException 入出力に失敗した場合 - * @see JarInputStream#JarInputStream(InputStream) - */ - public static JarInputStream create(final InputStream is) throws IOException { - return new JarInputStream(is); - } - - /** - * {@link JarInputStream#getNextJarEntry()}の例外処理をラップするメソッド。 - * - * @param is {@link JarInputStream} - * @return {@link JarEntry} - * @throws IOException 入出力に失敗した場合 - * @see JarInputStream#getNextJarEntry() - */ - public static JarEntry getNextJarEntry(final JarInputStream is) throws IOException { - return is.getNextJarEntry(); - } - - private JarInputStreamUtil() { - throw new JiemamyError("不到達ポイント"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.IOException; +import java.io.InputStream; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link JarInputStream}用のユーティリティクラス。 + * + * @author j5ik2o + */ +public class JarInputStreamUtil { + + /** + * {@link JarInputStream}を作成する。 + * + * @param is {@link InputStream} + * @return {@link JarInputStream} + * @throws IOException 入出力に失敗した場合 + * @see JarInputStream#JarInputStream(InputStream) + */ + public static JarInputStream create(final InputStream is) throws IOException { + return new JarInputStream(is); + } + + /** + * {@link JarInputStream#getNextJarEntry()}の例外処理をラップするメソッド。 + * + * @param is {@link JarInputStream} + * @return {@link JarEntry} + * @throws IOException 入出力に失敗した場合 + * @see JarInputStream#getNextJarEntry() + */ + public static JarEntry getNextJarEntry(final JarInputStream is) throws IOException { + return is.getNextJarEntry(); + } + + private JarInputStreamUtil() { + throw new JiemamyError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarInputStreamUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarURLConnectionUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarURLConnectionUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarURLConnectionUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,48 +1,48 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.IOException; -import java.net.JarURLConnection; -import java.util.jar.JarFile; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link JarURLConnection}用のユーティリティクラス。 - * - * @author j5ik2o - * - */ -public class JarURLConnectionUtil { - - /** - * {@link JarURLConnection#getJarFile()}の例外処理をラップするメソッドである。 - * - * @param conn {@link JarURLConnection} - * @return {@link JarFile} - * @throws IOException JarURLConnection#getJarFileが失敗した場合 - */ - public static JarFile getJarFile(JarURLConnection conn) throws IOException { - return conn.getJarFile(); - } - - private JarURLConnectionUtil() { - throw new JiemamyError("不到達ポイント"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.IOException; +import java.net.JarURLConnection; +import java.util.jar.JarFile; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link JarURLConnection}用のユーティリティクラス。 + * + * @author j5ik2o + * + */ +public class JarURLConnectionUtil { + + /** + * {@link JarURLConnection#getJarFile()}の例外処理をラップするメソッドである。 + * + * @param conn {@link JarURLConnection} + * @return {@link JarFile} + * @throws IOException JarURLConnection#getJarFileが失敗した場合 + */ + public static JarFile getJarFile(JarURLConnection conn) throws IOException { + return conn.getJarFile(); + } + + private JarURLConnectionUtil() { + throw new JiemamyError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JarURLConnectionUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JmIOUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JmIOUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JmIOUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,134 +1,134 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/07/26 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -import org.apache.commons.io.IOUtils; - -import org.jiemamy.utils.metadata.TypeSafeDatabaseMetaData.TypeSafeResultSet; - -/** - * 入出力ユーティリティクラス。 - * - * <p>{@link IOUtils}に対する追加分と考えるとよい。</p> - * - * @author daisuke - */ -public final class JmIOUtil { - -// /** -// * 無条件にリソースを閉じる。 -// * -// * <p>{@link Closeable#close()} と等価であるが、例外を無視する。 -// * 主に finally 句内で使われることを想定している。</p> -// * -// * @param closeable 閉じる対象。nullでも、既にclose済みであっても構わない -// */ -// public static void closeQuietly(Closeable closeable) { -// if (closeable != null) { -// try { -// closeable.close(); -// } catch (IOException ignore) { -// // ignore -// } -// } -// } - - /** - * 無条件にリソースを閉じる。 - * - * <p>{@link Connection#close()} と等価であるが、例外を無視する。 - * 主に finally 句内で使われることを想定している。</p> - * - * @param connection 閉じる対象。nullでも、既にclose済みであっても構わない - */ - public static void closeQuietly(Connection connection) { - if (connection != null) { - try { - connection.close(); - } catch (SQLException ignore) { - // ignore - } - } - } - - /** - * 無条件にリソースを閉じる。 - * - * <p>{@link TypeSafeResultSet#close()} と等価であるが、例外を無視する。 - * 主に finally 句内で使われることを想定している。</p> - * - * @param columnsResult 閉じる対象。nullでも、既にclose済みであっても構わない - */ - public static void closeQuietly(TypeSafeResultSet<?> columnsResult) { - if (columnsResult != null) { - try { - columnsResult.close(); - } catch (SQLException e) { - // ignore - } - } - } - - /** - * 無条件にリソースを閉じる。 - * - * <p>{@link ResultSet#close()} と等価であるが、例外を無視する。 - * 主に finally 句内で使われることを想定している。</p> - * - * @param resultSet 閉じる対象。nullでも、既にclose済みであっても構わない - */ - public static void closeQuietly(ResultSet resultSet) { - if (resultSet != null) { - try { - resultSet.close(); - } catch (SQLException ignore) { - // ignore - } - } - } - - /** - * 無条件にリソースを閉じる。 - * - * <p>{@link Statement#close()} と等価であるが、例外を無視する。 - * 主に finally 句内で使われることを想定している。</p> - * - * @param statement 閉じる対象。nullでも、既にclose済みであっても構わない - */ - public static void closeQuietly(Statement statement) { - if (statement != null) { - try { - statement.close(); - } catch (SQLException ignore) { - // ignore - } - } - } - - /** - * ユーティリティクラス。 - */ - private JmIOUtil() { - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/07/26 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import org.apache.commons.io.IOUtils; + +import org.jiemamy.utils.metadata.TypeSafeDatabaseMetaData.TypeSafeResultSet; + +/** + * 入出力ユーティリティクラス。 + * + * <p>{@link IOUtils}に対する追加分と考えるとよい。</p> + * + * @author daisuke + */ +public final class JmIOUtil { + +// /** +// * 無条件にリソースを閉じる。 +// * +// * <p>{@link Closeable#close()} と等価であるが、例外を無視する。 +// * 主に finally 句内で使われることを想定している。</p> +// * +// * @param closeable 閉じる対象。nullでも、既にclose済みであっても構わない +// */ +// public static void closeQuietly(Closeable closeable) { +// if (closeable != null) { +// try { +// closeable.close(); +// } catch (IOException ignore) { +// // ignore +// } +// } +// } + + /** + * 無条件にリソースを閉じる。 + * + * <p>{@link Connection#close()} と等価であるが、例外を無視する。 + * 主に finally 句内で使われることを想定している。</p> + * + * @param connection 閉じる対象。nullでも、既にclose済みであっても構わない + */ + public static void closeQuietly(Connection connection) { + if (connection != null) { + try { + connection.close(); + } catch (SQLException ignore) { + // ignore + } + } + } + + /** + * 無条件にリソースを閉じる。 + * + * <p>{@link TypeSafeResultSet#close()} と等価であるが、例外を無視する。 + * 主に finally 句内で使われることを想定している。</p> + * + * @param columnsResult 閉じる対象。nullでも、既にclose済みであっても構わない + */ + public static void closeQuietly(TypeSafeResultSet<?> columnsResult) { + if (columnsResult != null) { + try { + columnsResult.close(); + } catch (SQLException e) { + // ignore + } + } + } + + /** + * 無条件にリソースを閉じる。 + * + * <p>{@link ResultSet#close()} と等価であるが、例外を無視する。 + * 主に finally 句内で使われることを想定している。</p> + * + * @param resultSet 閉じる対象。nullでも、既にclose済みであっても構わない + */ + public static void closeQuietly(ResultSet resultSet) { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException ignore) { + // ignore + } + } + } + + /** + * 無条件にリソースを閉じる。 + * + * <p>{@link Statement#close()} と等価であるが、例外を無視する。 + * 主に finally 句内で使われることを想定している。</p> + * + * @param statement 閉じる対象。nullでも、既にclose済みであっても構わない + */ + public static void closeQuietly(Statement statement) { + if (statement != null) { + try { + statement.close(); + } catch (SQLException ignore) { + // ignore + } + } + } + + /** + * ユーティリティクラス。 + */ + private JmIOUtil() { + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JmIOUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JmStringUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JmStringUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JmStringUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,208 +1,208 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/06/09 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.Locale; - -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; - -/** - * Stringユーティリティ。 - * - * @author daisuke - * @author wencheng - */ -public final class JmStringUtil { - - /** - * 大文字小文字を無視した条件下で、配列中に指定した文字列を含むかどうかを調べる。 - * - * @param array 調査対象配列 - * @param stringToFind 探す文字列 - * @return 含む場合は{@code true}、そうでない場合は{@code false} - */ - public static boolean containsIgnoreCase(String[] array, String stringToFind) { - return indexOfIgnoreCase(array, stringToFind) != ArrayUtils.INDEX_NOT_FOUND; - } - - /** - * 大文字小文字を無視した条件下で、配列中に指定した文字列のインデックスを調べる。 - * - * @param array 調査対象配列 - * @param stringToFind 探す文字列 - * @return インデックス番号 - */ - public static int indexOfIgnoreCase(String[] array, String stringToFind) { - return indexOfIgnoreCase(array, stringToFind, 0); - } - - /** - * 大文字小文字を無視した条件下で、配列中に指定した文字列のインデックスを調べる。 - * - * @param array 調査対象配列 - * @param stringToFind 探す文字列 - * @param startIndex 調査開始インデックス - * @return インデックス番号 - */ - public static int indexOfIgnoreCase(String[] array, String stringToFind, int startIndex) { - if (array == null) { - return ArrayUtils.INDEX_NOT_FOUND; - } - if (startIndex < 0) { - startIndex = 0; - } - if (stringToFind == null) { - for (int i = startIndex; i < array.length; i++) { - if (array[i] == null) { - return i; - } - } - } else { - for (int i = startIndex; i < array.length; i++) { - if (stringToFind.equalsIgnoreCase(array[i])) { - return i; - } - } - } - return ArrayUtils.INDEX_NOT_FOUND; - } - - /** - * 文字列の1文字目を大文字にする。 - * - * @param str 入力文字列 - * @return 出力文字列 - */ - public static String toCapital(final String str) { - final char[] ch = str.toCharArray(); - ch[0] = Character.toUpperCase(ch[0]); - return new String(ch); - } - - /** - * SQL名(ex. AGILE_DATABASE)からJavaクラス名(ex. AgileDatabase)を生成する。 - * - * @param str SQL名 - * @return Javaクラス名 - */ - public static String toJavaClassName(final String str) { - return toCapital(toJavaName(str)); - } - - /** - * SQL名(ex. AGILE_DATABASE)からJavaクラス名(ex. AgileDatabase)を生成する。 prifixが存在した場合、取り除く。 - * - * @param str SQL名 - * @param prefix 接頭辞 - * @return Javaクラス名 - */ - public static String toJavaClassName(final String str, final String prefix) { - return toCapital(toJavaName(str, prefix)); - } - - /** - * SQL名(ex. AGILE_DATABASE)からJava名(ex. agileDatabase)を生成する。 - * - * @param str SQL名 - * @return Java名 - */ - public static String toJavaName(final String str) { - return toJavaName(str, null); - } - - /** - * SQL名(ex. AGILE_DATABASE)からJava名(ex. agileDatabase)を生成する。 prifixが存在した場合、取り除く。 - * - * @param str SQL名 - * @param prefix 接頭辞 - * @return Java名 - */ - public static String toJavaName(final String str, final String prefix) { - if (str == null) { - return str; - } - String low; - if (prefix != null && str.startsWith(prefix)) { - low = str.replaceFirst(prefix, "").toLowerCase(Locale.getDefault()); - } else { - low = str.toLowerCase(Locale.getDefault()); - } - final StringBuilder sb = new StringBuilder(low); - for (int i = 0; i < sb.length(); i++) { - final char c = sb.charAt(i); - if (c == '_') { - sb.deleteCharAt(i); - sb.setCharAt(i, Character.toUpperCase(sb.charAt(i))); - } - } - return sb.toString(); - } - - /** - * Java名(ex. AgileDatabase, agileDatabase)からSQL名(ex. AGILE_DATABASE)を生成する。 - * - * @param str Java名 - * @return SQL名 - */ - public static String toSQLName(final String str) { - return toSQLName(str, StringUtils.EMPTY); - } - - /** - * Java名(ex. AgileDatabase, agileDatabase)からSQL名(ex. AGILE_DATABASE)を生成する。 prifixを付加する。 - * - * @param str Java名 - * @param prefix 接頭辞 - * @return SQL名 - */ - public static String toSQLName(final String str, final String prefix) { - if (str == null || str.length() == 0) { - return str; - } - final StringBuilder sb = new StringBuilder(str); - for (int i = 0; i < sb.length(); i++) { - final char c = sb.charAt(i); - if (Character.isUpperCase(c)) { - sb.insert(i++, "_"); - } else { - sb.setCharAt(i, Character.toUpperCase(c)); - } - } - if (prefix != null && prefix.length() > 0) { - sb.insert(0, prefix.toUpperCase(Locale.getDefault())); - } - return sb.toString(); - } - - /** - * 文字列の1文字目を小文字にする。 - * - * @param str 入力文字列 - * @return 出力文字列 - */ - public static String toUnCapital(String str) { - final char[] ch = str.toCharArray(); - ch[0] = Character.toLowerCase(ch[0]); - return new String(ch); - } - - private JmStringUtil() { - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/06/09 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.Locale; + +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; + +/** + * Stringユーティリティ。 + * + * @author daisuke + * @author wencheng + */ +public final class JmStringUtil { + + /** + * 大文字小文字を無視した条件下で、配列中に指定した文字列を含むかどうかを調べる。 + * + * @param array 調査対象配列 + * @param stringToFind 探す文字列 + * @return 含む場合は{@code true}、そうでない場合は{@code false} + */ + public static boolean containsIgnoreCase(String[] array, String stringToFind) { + return indexOfIgnoreCase(array, stringToFind) != ArrayUtils.INDEX_NOT_FOUND; + } + + /** + * 大文字小文字を無視した条件下で、配列中に指定した文字列のインデックスを調べる。 + * + * @param array 調査対象配列 + * @param stringToFind 探す文字列 + * @return インデックス番号 + */ + public static int indexOfIgnoreCase(String[] array, String stringToFind) { + return indexOfIgnoreCase(array, stringToFind, 0); + } + + /** + * 大文字小文字を無視した条件下で、配列中に指定した文字列のインデックスを調べる。 + * + * @param array 調査対象配列 + * @param stringToFind 探す文字列 + * @param startIndex 調査開始インデックス + * @return インデックス番号 + */ + public static int indexOfIgnoreCase(String[] array, String stringToFind, int startIndex) { + if (array == null) { + return ArrayUtils.INDEX_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + if (stringToFind == null) { + for (int i = startIndex; i < array.length; i++) { + if (array[i] == null) { + return i; + } + } + } else { + for (int i = startIndex; i < array.length; i++) { + if (stringToFind.equalsIgnoreCase(array[i])) { + return i; + } + } + } + return ArrayUtils.INDEX_NOT_FOUND; + } + + /** + * 文字列の1文字目を大文字にする。 + * + * @param str 入力文字列 + * @return 出力文字列 + */ + public static String toCapital(final String str) { + final char[] ch = str.toCharArray(); + ch[0] = Character.toUpperCase(ch[0]); + return new String(ch); + } + + /** + * SQL名(ex. AGILE_DATABASE)からJavaクラス名(ex. AgileDatabase)を生成する。 + * + * @param str SQL名 + * @return Javaクラス名 + */ + public static String toJavaClassName(final String str) { + return toCapital(toJavaName(str)); + } + + /** + * SQL名(ex. AGILE_DATABASE)からJavaクラス名(ex. AgileDatabase)を生成する。 prifixが存在した場合、取り除く。 + * + * @param str SQL名 + * @param prefix 接頭辞 + * @return Javaクラス名 + */ + public static String toJavaClassName(final String str, final String prefix) { + return toCapital(toJavaName(str, prefix)); + } + + /** + * SQL名(ex. AGILE_DATABASE)からJava名(ex. agileDatabase)を生成する。 + * + * @param str SQL名 + * @return Java名 + */ + public static String toJavaName(final String str) { + return toJavaName(str, null); + } + + /** + * SQL名(ex. AGILE_DATABASE)からJava名(ex. agileDatabase)を生成する。 prifixが存在した場合、取り除く。 + * + * @param str SQL名 + * @param prefix 接頭辞 + * @return Java名 + */ + public static String toJavaName(final String str, final String prefix) { + if (str == null) { + return str; + } + String low; + if (prefix != null && str.startsWith(prefix)) { + low = str.replaceFirst(prefix, "").toLowerCase(Locale.getDefault()); + } else { + low = str.toLowerCase(Locale.getDefault()); + } + final StringBuilder sb = new StringBuilder(low); + for (int i = 0; i < sb.length(); i++) { + final char c = sb.charAt(i); + if (c == '_') { + sb.deleteCharAt(i); + sb.setCharAt(i, Character.toUpperCase(sb.charAt(i))); + } + } + return sb.toString(); + } + + /** + * Java名(ex. AgileDatabase, agileDatabase)からSQL名(ex. AGILE_DATABASE)を生成する。 + * + * @param str Java名 + * @return SQL名 + */ + public static String toSQLName(final String str) { + return toSQLName(str, StringUtils.EMPTY); + } + + /** + * Java名(ex. AgileDatabase, agileDatabase)からSQL名(ex. AGILE_DATABASE)を生成する。 prifixを付加する。 + * + * @param str Java名 + * @param prefix 接頭辞 + * @return SQL名 + */ + public static String toSQLName(final String str, final String prefix) { + if (str == null || str.length() == 0) { + return str; + } + final StringBuilder sb = new StringBuilder(str); + for (int i = 0; i < sb.length(); i++) { + final char c = sb.charAt(i); + if (Character.isUpperCase(c)) { + sb.insert(i++, "_"); + } else { + sb.setCharAt(i, Character.toUpperCase(c)); + } + } + if (prefix != null && prefix.length() > 0) { + sb.insert(0, prefix.toUpperCase(Locale.getDefault())); + } + return sb.toString(); + } + + /** + * 文字列の1文字目を小文字にする。 + * + * @param str 入力文字列 + * @return 出力文字列 + */ + public static String toUnCapital(String str) { + final char[] ch = str.toCharArray(); + ch[0] = Character.toLowerCase(ch[0]); + return new String(ch); + } + + private JmStringUtil() { + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/JmStringUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/LinkedEssentialQueue.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/LinkedEssentialQueue.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/LinkedEssentialQueue.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,80 +1,80 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/16 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.NoSuchElementException; - -/** - * {@link EssentialQueue}の{@link LinkedList}を用いた実装。 - * - * @param <E> 要素の型 - * @author daisuke - */ -public class LinkedEssentialQueue<E> implements EssentialQueue<E> { - - private LinkedList<E> linkedList = new LinkedList<E>(); - - - public void clear() { - linkedList.clear(); - } - - public E dequeue() { - return linkedList.poll(); - } - - public void enqueue(E element) { - linkedList.offer(element); - } - - public void enqueue(EssentialQueue<E> queue) { - try { - while (true) { - E element = queue.dequeue(); - enqueue(element); - } - } catch (NoSuchElementException e) { - // ループを抜ける。 - } - } - - public boolean isEmpty() { - return linkedList.isEmpty(); - } - - public Iterator<E> iterator() { - return linkedList.iterator(); - } - - public E peek() { - return linkedList.peek(); - } - - public int size() { - return linkedList.size(); - } - - @Override - public String toString() { - return linkedList.toString(); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/16 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.NoSuchElementException; + +/** + * {@link EssentialQueue}の{@link LinkedList}を用いた実装。 + * + * @param <E> 要素の型 + * @author daisuke + */ +public class LinkedEssentialQueue<E> implements EssentialQueue<E> { + + private LinkedList<E> linkedList = new LinkedList<E>(); + + + public void clear() { + linkedList.clear(); + } + + public E dequeue() { + return linkedList.poll(); + } + + public void enqueue(E element) { + linkedList.offer(element); + } + + public void enqueue(EssentialQueue<E> queue) { + try { + while (true) { + E element = queue.dequeue(); + enqueue(element); + } + } catch (NoSuchElementException e) { + // ループを抜ける。 + } + } + + public boolean isEmpty() { + return linkedList.isEmpty(); + } + + public Iterator<E> iterator() { + return linkedList.iterator(); + } + + public E peek() { + return linkedList.peek(); + } + + public int size() { + return linkedList.size(); + } + + @Override + public String toString() { + return linkedList.toString(); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/LinkedEssentialQueue.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ListUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ListUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ListUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,81 +1,81 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/02/10 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.Collections; -import java.util.List; - -import org.apache.commons.lang.Validate; - -/** - * {@link List}を扱うユーティリティクラス。 - * - * @author daisuke - */ -public class ListUtil { - -// /** -// * リストの指定したindexの要素を、次の要素と入れ替える。 -// * -// * @param list 対象リスト -// * @param index インデックス -// * @throws IllegalArgumentException 引数に{@code null}を与えた場合 -// * @throws IllegalArgumentException indexが負の数の場合 -// * @throws IndexOutOfBoundsException -// */ -// public static void moveDown(List<?> list, int index) { -// Validate.notNull(list); -// Validate.isTrue(index >= 0); -// Collections.swap(list, index, index + 1); -// } -// -// /** -// * リストの指定したindexの要素を、前の要素と入れ替える。 -// * -// * @param list 対象リスト -// * @param index インデックス -// * @throws IllegalArgumentException 引数に{@code null}を与えた場合 -// * @throws IllegalArgumentException indexが負の数の場合 -// * @throws IndexOutOfBoundsException -// */ -// public static void moveUp(List<?> list, int index) { -// Validate.notNull(list); -// Validate.isTrue(index >= 0); -// Collections.swap(list, index, index - 1); -// } - /** - * リストの順序を反転させる。 - * - * @param list 対象リスト - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static void reverse(List<?> list) { - Validate.notNull(list); - int center = list.size() / 2; - int end = list.size() - 1; - - for (int i = 0; i < center; i++) { - Collections.swap(list, i, end - i); - } - } - - private ListUtil() { - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/10 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.Validate; + +/** + * {@link List}を扱うユーティリティクラス。 + * + * @author daisuke + */ +public class ListUtil { + +// /** +// * リストの指定したindexの要素を、次の要素と入れ替える。 +// * +// * @param list 対象リスト +// * @param index インデックス +// * @throws IllegalArgumentException 引数に{@code null}を与えた場合 +// * @throws IllegalArgumentException indexが負の数の場合 +// * @throws IndexOutOfBoundsException +// */ +// public static void moveDown(List<?> list, int index) { +// Validate.notNull(list); +// Validate.isTrue(index >= 0); +// Collections.swap(list, index, index + 1); +// } +// +// /** +// * リストの指定したindexの要素を、前の要素と入れ替える。 +// * +// * @param list 対象リスト +// * @param index インデックス +// * @throws IllegalArgumentException 引数に{@code null}を与えた場合 +// * @throws IllegalArgumentException indexが負の数の場合 +// * @throws IndexOutOfBoundsException +// */ +// public static void moveUp(List<?> list, int index) { +// Validate.notNull(list); +// Validate.isTrue(index >= 0); +// Collections.swap(list, index, index - 1); +// } + /** + * リストの順序を反転させる。 + * + * @param list 対象リスト + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static void reverse(List<?> list) { + Validate.notNull(list); + int center = list.size() / 2; + int end = list.size() - 1; + + for (int i = 0; i < center; i++) { + Collections.swap(list, i, end - i); + } + } + + private ListUtil() { + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ListUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/LogMarker.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/LogMarker.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/LogMarker.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,204 +1,204 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/02/23 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.slf4j.Marker; -import org.slf4j.helpers.BasicMarker; - -/** - * SLF4Jのログマーカーを提供する定数クラス。 - * - * <p>cf. <a - * href="http://d.hatena.ne.jp/taichitaichi/20090220/1235124140">http://d.hatena.ne.jp/taichitaichi/20090220/1235124140</a></p> - * - * @see BasicMarker - * @author daisuke - */ -public enum LogMarker implements Marker { - - /** Jiemamy用 SLF4Jのルートログマーカー */ - MARKER_ROOT("org.jiemamy"), - - /** 設計判断を伴う処理に関連する項目。アドインやプラグインに関連する部分など */ - DESIGN("org.jiemamy.design"), - - /** ファイルやネットワーク、他の依存ライブラリに対するインターフェースに関連する項目 */ - BOUNDARY("org.jiemamy.boundary"), - - /** ライブラリ内に定義されているオブジェクトのライフサイクルに関連する項目 */ - LIFECYCLE("org.jiemamy.lifecycle"), - - /** - * 処理の中で、詳細な情報を出力する為の項目 - * - * <p>このマーカは、主にライブリやフレームワークの実装者が、バグの調査を目的として使う</p> - */ - DETAIL("org.jiemamy" + ".detail"); - - private static final String OPEN = "[ "; - - private static final String CLOSE = " ]"; - - private static final String SEP = ", "; - - static { - for (Marker m : values()) { - if (m == MARKER_ROOT) { - continue; - } - MARKER_ROOT.add(m); - } - } - - private final String name; - - private List<Marker> refereceList; - - - LogMarker(String name) { - this.name = name; - } - - public void add(Marker reference) { - if (reference == null) { - throw new IllegalArgumentException("A null value cannot be added to a Marker as reference."); - } - - // no point in adding the reference multiple times - if (this.contains(reference)) { - return; - - } else if (reference.contains(this)) { // avoid recursion - // a potential reference should not its future "parent" as a reference - return; - } else { - // let's add the reference - if (refereceList == null) { - refereceList = new Vector<Marker>(); - } - refereceList.add(reference); - } - } - - public boolean contains(Marker other) { - if (other == null) { - throw new IllegalArgumentException("Other cannot be null"); - } - - if (equals(other)) { - return true; - } - - if (hasReferences()) { - for (int i = 0; i < refereceList.size(); i++) { - Marker ref = refereceList.get(i); - if (ref.contains(other)) { - return true; - } - } - } - return false; - } - - public boolean contains(String name) { - if (name == null) { - throw new IllegalArgumentException("Other cannot be null"); - } - - if (this.name.equals(name)) { - return true; - } - - if (hasReferences()) { - for (int i = 0; i < refereceList.size(); i++) { - Marker ref = refereceList.get(i); - if (ref.contains(name)) { - return true; - } - } - } - return false; - } - - public String getName() { - return name; - } - - @Deprecated - public boolean hasChildren() { - return hasReferences(); - } - - public boolean hasReferences() { - return refereceList != null && refereceList.size() > 0; - } - - public Iterator<Marker> iterator() { - if (refereceList != null) { - return refereceList.iterator(); - } else { - @SuppressWarnings("unchecked") - Iterator<Marker> result = Collections.EMPTY_LIST.iterator(); - return result; - } - } - - public boolean remove(Marker referenceToRemove) { - if (refereceList == null) { - return false; - } - - int size = refereceList.size(); - for (int i = 0; i < size; i++) { - Marker m = refereceList.get(i); - if (referenceToRemove.equals(m)) { - refereceList.remove(i); - return true; - } - } - return false; - } - - @Override - public String toString() { - if (!hasReferences()) { - return getName(); - } - Iterator<Marker> it = iterator(); - Marker reference; - StringBuffer sb = new StringBuffer(getName()); - sb.append(' ').append(OPEN); - while (it.hasNext()) { - reference = it.next(); - sb.append(reference.getName()); - if (it.hasNext()) { - sb.append(SEP); - } - } - sb.append(CLOSE); - - return sb.toString(); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/23 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +import org.slf4j.Marker; +import org.slf4j.helpers.BasicMarker; + +/** + * SLF4Jのログマーカーを提供する定数クラス。 + * + * <p>cf. <a + * href="http://d.hatena.ne.jp/taichitaichi/20090220/1235124140">http://d.hatena.ne.jp/taichitaichi/20090220/1235124140</a></p> + * + * @see BasicMarker + * @author daisuke + */ +public enum LogMarker implements Marker { + + /** Jiemamy用 SLF4Jのルートログマーカー */ + MARKER_ROOT("org.jiemamy"), + + /** 設計判断を伴う処理に関連する項目。アドインやプラグインに関連する部分など */ + DESIGN("org.jiemamy.design"), + + /** ファイルやネットワーク、他の依存ライブラリに対するインターフェースに関連する項目 */ + BOUNDARY("org.jiemamy.boundary"), + + /** ライブラリ内に定義されているオブジェクトのライフサイクルに関連する項目 */ + LIFECYCLE("org.jiemamy.lifecycle"), + + /** + * 処理の中で、詳細な情報を出力する為の項目 + * + * <p>このマーカは、主にライブリやフレームワークの実装者が、バグの調査を目的として使う</p> + */ + DETAIL("org.jiemamy" + ".detail"); + + private static final String OPEN = "[ "; + + private static final String CLOSE = " ]"; + + private static final String SEP = ", "; + + static { + for (Marker m : values()) { + if (m == MARKER_ROOT) { + continue; + } + MARKER_ROOT.add(m); + } + } + + private final String name; + + private List<Marker> refereceList; + + + LogMarker(String name) { + this.name = name; + } + + public void add(Marker reference) { + if (reference == null) { + throw new IllegalArgumentException("A null value cannot be added to a Marker as reference."); + } + + // no point in adding the reference multiple times + if (this.contains(reference)) { + return; + + } else if (reference.contains(this)) { // avoid recursion + // a potential reference should not its future "parent" as a reference + return; + } else { + // let's add the reference + if (refereceList == null) { + refereceList = new Vector<Marker>(); + } + refereceList.add(reference); + } + } + + public boolean contains(Marker other) { + if (other == null) { + throw new IllegalArgumentException("Other cannot be null"); + } + + if (equals(other)) { + return true; + } + + if (hasReferences()) { + for (int i = 0; i < refereceList.size(); i++) { + Marker ref = refereceList.get(i); + if (ref.contains(other)) { + return true; + } + } + } + return false; + } + + public boolean contains(String name) { + if (name == null) { + throw new IllegalArgumentException("Other cannot be null"); + } + + if (this.name.equals(name)) { + return true; + } + + if (hasReferences()) { + for (int i = 0; i < refereceList.size(); i++) { + Marker ref = refereceList.get(i); + if (ref.contains(name)) { + return true; + } + } + } + return false; + } + + public String getName() { + return name; + } + + @Deprecated + public boolean hasChildren() { + return hasReferences(); + } + + public boolean hasReferences() { + return refereceList != null && refereceList.size() > 0; + } + + public Iterator<Marker> iterator() { + if (refereceList != null) { + return refereceList.iterator(); + } else { + @SuppressWarnings("unchecked") + Iterator<Marker> result = Collections.EMPTY_LIST.iterator(); + return result; + } + } + + public boolean remove(Marker referenceToRemove) { + if (refereceList == null) { + return false; + } + + int size = refereceList.size(); + for (int i = 0; i < size; i++) { + Marker m = refereceList.get(i); + if (referenceToRemove.equals(m)) { + refereceList.remove(i); + return true; + } + } + return false; + } + + @Override + public String toString() { + if (!hasReferences()) { + return getName(); + } + Iterator<Marker> it = iterator(); + Marker reference; + StringBuffer sb = new StringBuffer(getName()); + sb.append(' ').append(OPEN); + while (it.hasNext()) { + reference = it.next(); + sb.append(reference.getName()); + if (it.hasNext()) { + sb.append(SEP); + } + } + sb.append(CLOSE); + + return sb.toString(); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/LogMarker.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/MethodUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/MethodUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/MethodUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,387 +1,387 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link Method}用のユーティリティクラス。 - * - * @author j5ik2o - * - */ -public class MethodUtil { - - /** バッファサイズ */ - private static final int BUFF_SIZE = 100; - - private static final Method IS_BRIDGE_METHOD = getIsBridgeMethod(); - - private static final Method IS_SYNTHETIC_METHOD = getIsSyntheticMethod(); - - /** {@link #getElementTypeOfCollectionFromParameterType(Method, int)}への定数参照。*/ - protected static final Method GET_ELEMENT_TYPE_OF_COLLECTION_FROM_PARAMETER_METHOD = - getElementTypeFromParameterMethod("Collection"); - - /** {@link #getElementTypeOfCollectionFromReturnType(Method)}への定数参照。*/ - protected static final Method GET_ELEMENT_TYPE_OF_COLLECTION_FROM_RETURN_METHOD = - getElementTypeFromReturnMethod("Collection"); - - /** {@link #getElementTypeOfListFromParameterType(Method, int)}への定数参照。*/ - protected static final Method GET_ELEMENT_TYPE_OF_LIST_FROM_PARAMETER_METHOD = - getElementTypeFromParameterMethod("List"); - - /** {@link #getElementTypeOfListFromReturnType(Method)}への定数参照。*/ - protected static final Method GET_ELEMENT_TYPE_OF_LIST_FROM_RETURN_METHOD = getElementTypeFromReturnMethod("List"); - - /** {@link #getElementTypeOfSetFromParameterType(Method, int)}への定数参照。*/ - protected static final Method GET_ELEMENT_TYPE_OF_SET_FROM_PARAMETER_METHOD = - getElementTypeFromParameterMethod("Set"); - - /** {@link #getElementTypeOfSetFromReturnType(Method)}への定数参照。*/ - protected static final Method GET_ELEMENT_TYPE_OF_SET_FROM_RETURN_METHOD = getElementTypeFromReturnMethod("Set"); - - - /** - * <code>ReflectionUtil#getElementTypeOf<var>Xxx</var>FromParameter</code>の{@link Method}を取得する。 - * - * @param type 取得するメソッドが対象とする型名 - * - * @return {@link Method} - */ - protected static Method getElementTypeFromParameterMethod(final String type) { - try { - final Class<?> reflectionUtilClass = ReflectionUtil.class; - return reflectionUtilClass.getMethod("getElementTypeOf" + type + "FromParameterType", new Class[] { - Method.class, - int.class - }); - } catch (final Throwable ignore) { - // ignore - } - return null; - } - - /** - * <code>ReflectionUtil#getElementTypeOf<var>Xxx</var>FromReturn</code>の{@link Method}を取得する。 - * - * @param type 取得するメソッドが対象とする型名 - * @return {@link Method} - */ - protected static Method getElementTypeFromReturnMethod(final String type) { - try { - final Class<?> reflectionUtilClass = ReflectionUtil.class; - return reflectionUtilClass.getMethod("getElementTypeOf" + type + "FromReturnType", new Class[] { - Method.class - }); - } catch (final Throwable ignore) { - // ignore - } - return null; - } - - /** - * メソッドの引数型 (パラメタ化されたコレクション)の要素型を取得する。 - * - * @param method メソッド - * @param position パラメタ化されたコレクションが宣言されているメソッド引数の位置 - * @return 指定されたメソッドの引数型として宣言されているパラメタ化されたコレクションの要素型 - * @throws InvocationTargetException メソッドが例外をスローする場合 - * @throws IllegalAccessException メソッドにアクセスできない場合 - * @throws IllegalArgumentException 引数が正しくない場合 - */ - public static Class<?> getElementTypeOfCollectionFromParameterType(final Method method, final int position) - throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { - return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_COLLECTION_FROM_PARAMETER_METHOD, null, new Object[] { - method, - Integer.valueOf(position) - }); - } - - /** - * 指定されたメソッドの戻り値型として宣言されているパラメタ化されたコレクションの要素型を取得する。 - * - * @param method メソッド - * @return 指定されたメソッドの戻り値型として宣言されているパラメタ化されたコレクションの要素型 - * @throws InvocationTargetException メソッドが例外をスローする場合 - * @throws IllegalAccessException メソッドにアクセスできない場合 - * @throws IllegalArgumentException 引数が正しくない場合 - */ - public static Class<?> getElementTypeOfCollectionFromReturnType(final Method method) - throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { - return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_COLLECTION_FROM_RETURN_METHOD, null, new Object[] { - method - }); - } - - /** - * メソッドの引数型 (パラメタ化されたリスト) の要素型を取得する。 - * - * @param method メソッド - * @param position パラメタ化されたリストが宣言されているメソッド引数の位置 - * @return 指定されたメソッドの引数型として宣言されているパラメタ化されたリストの要素型 - * @throws InvocationTargetException メソッドが例外をスローする場合 - * @throws IllegalAccessException メソッドにアクセスできない場合 - * @throws IllegalArgumentException 引数が正しくない場合 - */ - public static Class<?> getElementTypeOfListFromParameterType(final Method method, final int position) - throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { - return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_LIST_FROM_PARAMETER_METHOD, null, new Object[] { - method, - Integer.valueOf(position) - }); - } - - /** - * 指定されたメソッドの戻り値型として宣言されているパラメタ化されたリストの要素型を取得する。 - * - * @param method メソッド - * @return 指定されたメソッドの戻り値型として宣言されているパラメタ化されたリストの要素型 - * @throws InvocationTargetException メソッドが例外をスローする場合 - * @throws IllegalAccessException メソッドにアクセスできない場合 - * @throws IllegalArgumentException 引数が正しくない場合 - */ - public static Class<?> getElementTypeOfListFromReturnType(final Method method) throws IllegalArgumentException, - IllegalAccessException, InvocationTargetException { - return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_LIST_FROM_RETURN_METHOD, null, new Object[] { - method - }); - } - - /** - * メソッドの引数型 (パラメタ化されたセット) の要素型を取得する。 - * - * @param method メソッド - * @param position パラメタ化されたコレクションが宣言されているメソッド引数の位置 - * @return 指定されたメソッドの引数型として宣言されているパラメタ化されたセットの要素型 - * @throws InvocationTargetException メソッドが例外をスローする場合 - * @throws IllegalAccessException メソッドにアクセスできない場合 - * @throws IllegalArgumentException 引数が正しくない場合 - */ - public static Class<?> getElementTypeOfSetFromParameterType(final Method method, final int position) - throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { - return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_SET_FROM_PARAMETER_METHOD, null, new Object[] { - method, - Integer.valueOf(position) - }); - } - - /** - * 指定されたメソッドの戻り値型として宣言されているパラメタ化されたセットの要素型を取得する。 - * - * @param method メソッド - * @return 指定されたメソッドの戻り値型として宣言されているパラメタ化されたセットの要素型 - * @throws InvocationTargetException メソッドが例外をスローする場合 - * @throws IllegalAccessException メソッドにアクセスできない場合 - * @throws IllegalArgumentException 引数が正しくない場合 - */ - public static Class<?> getElementTypeOfSetFromReturnType(final Method method) throws IllegalArgumentException, - IllegalAccessException, InvocationTargetException { - if (GET_ELEMENT_TYPE_OF_SET_FROM_RETURN_METHOD == null) { - return null; - } - return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_SET_FROM_RETURN_METHOD, null, new Object[] { - method - }); - } - - private static Method getIsBridgeMethod() { - try { - return Method.class.getMethod("isBridge", new Class<?>[] { - null - }); - } catch (final NoSuchMethodException e) { - return null; - } - } - - private static Method getIsSyntheticMethod() { - try { - return Method.class.getMethod("isSynthetic", new Class<?>[] { - null - }); - } catch (final NoSuchMethodException e) { - return null; - } - } - - /** - * シグニチャを取得する。 - * - * @param methodName メソッド名 - * @param argTypes 引数 - * @return シグニチャ - */ - public static String getSignature(String methodName, Class<?>[] argTypes) { - StringBuffer buf = new StringBuffer(BUFF_SIZE); - buf.append(methodName); - buf.append("("); - if (argTypes != null) { - for (int i = 0; i < argTypes.length; ++i) { - if (i > 0) { - buf.append(", "); - } - buf.append(argTypes[i].getName()); - } - } - buf.append(")"); - return buf.toString(); - } - - /** - * シグニチャを取得する。 - * - * @param methodName メソッド名 - * @param methodArgs メソッドの引数 - * @return シグニチャ - */ - public static String getSignature(String methodName, Object[] methodArgs) { - StringBuffer buf = new StringBuffer(BUFF_SIZE); - buf.append(methodName); - buf.append("("); - if (methodArgs != null) { - for (int i = 0; i < methodArgs.length; ++i) { - if (i > 0) { - buf.append(", "); - } - if (methodArgs[i] != null) { - buf.append(methodArgs[i].getClass().getName()); - } else { - buf.append("null"); - } - } - } - buf.append(")"); - return buf.toString(); - } - - /** - * {@link Method#invoke(Object, Object[])}の例外処理をラップする。 - * - * @param method メソッド - * @param target ターゲット - * @param args 引数 - * @return 戻り値 - * @throws IllegalAccessException メソッドにアクセスできない場合 - * @throws IllegalArgumentException 引数が正しくない場合 - * @throws InvocationTargetException メソッドが例外をスローする場合 - * @see Method#invoke(Object, Object[]) - */ - public static Object invoke(Method method, Object target, Object[] args) throws IllegalArgumentException, - IllegalAccessException, InvocationTargetException { - try { - return method.invoke(target, args); - } catch (InvocationTargetException ex) { - Throwable t = ex.getCause(); - if (t instanceof RuntimeException) { - throw (RuntimeException) t; - } - if (t instanceof Error) { - throw (Error) t; - } - throw ex; - } - } - - /** - * <code>abstract</code>かどうかを取得する。 - * - * @param method メソッド - * @return <code>abstract</code>かどうか - */ - public static boolean isAbstract(Method method) { - int mod = method.getModifiers(); - return Modifier.isAbstract(mod); - } - - /** - * ブリッジメソッドかどうか取得する。 - * - * @param method {@link Method} - * @return ブリッジメソッドかどうか - * @throws InvocationTargetException メソッドが例外をスローする場合 - * @throws IllegalAccessException メソッドにアクセス場合 - * @throws IllegalArgumentException 引数が正しくない場合 - */ - public static boolean isBridgeMethod(final Method method) throws IllegalArgumentException, IllegalAccessException, - InvocationTargetException { - if (IS_BRIDGE_METHOD == null) { - return false; - } - return ((Boolean) MethodUtil.invoke(IS_BRIDGE_METHOD, method, null)).booleanValue(); - } - - /** - * equalsメソッドかどうかを取得する。 - * - * @param method {@link Method} - * @return equalsメソッドかどうか - */ - public static boolean isEqualsMethod(Method method) { - return method != null && method.getName().equals("equals") && method.getReturnType() == boolean.class - && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class; - } - - /** - * hashCodeメソッドかどうか取得する。 - * - * @param method {@link Method} - * @return hashCodeメソッドかどうか - */ - public static boolean isHashCodeMethod(Method method) { - return method != null && method.getName().equals("hashCode") && method.getReturnType() == int.class - && method.getParameterTypes().length == 0; - } - - /** - * 合成メソッドかどうかを取得する。 - * - * @param method {@link Method} - * @return 合成メソッドかどうか - * @throws InvocationTargetException メソッドが例外をスローする場合 - * @throws IllegalAccessException メソッドにアクセス場合 - * @throws IllegalArgumentException 引数が正しくない場合 - */ - public static boolean isSyntheticMethod(final Method method) throws IllegalArgumentException, - IllegalAccessException, InvocationTargetException { - if (IS_SYNTHETIC_METHOD == null) { - return false; - } - return ((Boolean) MethodUtil.invoke(IS_SYNTHETIC_METHOD, method, null)).booleanValue(); - } - - /** - * toStringメソッドかどうか取得する。 - * - * @param method {@link Method} - * @return toStringメソッドかどうか - */ - public static boolean isToStringMethod(Method method) { - return method != null && method.getName().equals("toString") && method.getReturnType() == String.class - && method.getParameterTypes().length == 0; - } - - private MethodUtil() { - throw new JiemamyError("不到達ポイント"); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link Method}用のユーティリティクラス。 + * + * @author j5ik2o + * + */ +public class MethodUtil { + + /** バッファサイズ */ + private static final int BUFF_SIZE = 100; + + private static final Method IS_BRIDGE_METHOD = getIsBridgeMethod(); + + private static final Method IS_SYNTHETIC_METHOD = getIsSyntheticMethod(); + + /** {@link #getElementTypeOfCollectionFromParameterType(Method, int)}への定数参照。*/ + protected static final Method GET_ELEMENT_TYPE_OF_COLLECTION_FROM_PARAMETER_METHOD = + getElementTypeFromParameterMethod("Collection"); + + /** {@link #getElementTypeOfCollectionFromReturnType(Method)}への定数参照。*/ + protected static final Method GET_ELEMENT_TYPE_OF_COLLECTION_FROM_RETURN_METHOD = + getElementTypeFromReturnMethod("Collection"); + + /** {@link #getElementTypeOfListFromParameterType(Method, int)}への定数参照。*/ + protected static final Method GET_ELEMENT_TYPE_OF_LIST_FROM_PARAMETER_METHOD = + getElementTypeFromParameterMethod("List"); + + /** {@link #getElementTypeOfListFromReturnType(Method)}への定数参照。*/ + protected static final Method GET_ELEMENT_TYPE_OF_LIST_FROM_RETURN_METHOD = getElementTypeFromReturnMethod("List"); + + /** {@link #getElementTypeOfSetFromParameterType(Method, int)}への定数参照。*/ + protected static final Method GET_ELEMENT_TYPE_OF_SET_FROM_PARAMETER_METHOD = + getElementTypeFromParameterMethod("Set"); + + /** {@link #getElementTypeOfSetFromReturnType(Method)}への定数参照。*/ + protected static final Method GET_ELEMENT_TYPE_OF_SET_FROM_RETURN_METHOD = getElementTypeFromReturnMethod("Set"); + + + /** + * <code>ReflectionUtil#getElementTypeOf<var>Xxx</var>FromParameter</code>の{@link Method}を取得する。 + * + * @param type 取得するメソッドが対象とする型名 + * + * @return {@link Method} + */ + protected static Method getElementTypeFromParameterMethod(final String type) { + try { + final Class<?> reflectionUtilClass = ReflectionUtil.class; + return reflectionUtilClass.getMethod("getElementTypeOf" + type + "FromParameterType", new Class[] { + Method.class, + int.class + }); + } catch (final Throwable ignore) { + // ignore + } + return null; + } + + /** + * <code>ReflectionUtil#getElementTypeOf<var>Xxx</var>FromReturn</code>の{@link Method}を取得する。 + * + * @param type 取得するメソッドが対象とする型名 + * @return {@link Method} + */ + protected static Method getElementTypeFromReturnMethod(final String type) { + try { + final Class<?> reflectionUtilClass = ReflectionUtil.class; + return reflectionUtilClass.getMethod("getElementTypeOf" + type + "FromReturnType", new Class[] { + Method.class + }); + } catch (final Throwable ignore) { + // ignore + } + return null; + } + + /** + * メソッドの引数型 (パラメタ化されたコレクション)の要素型を取得する。 + * + * @param method メソッド + * @param position パラメタ化されたコレクションが宣言されているメソッド引数の位置 + * @return 指定されたメソッドの引数型として宣言されているパラメタ化されたコレクションの要素型 + * @throws InvocationTargetException メソッドが例外をスローする場合 + * @throws IllegalAccessException メソッドにアクセスできない場合 + * @throws IllegalArgumentException 引数が正しくない場合 + */ + public static Class<?> getElementTypeOfCollectionFromParameterType(final Method method, final int position) + throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { + return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_COLLECTION_FROM_PARAMETER_METHOD, null, new Object[] { + method, + Integer.valueOf(position) + }); + } + + /** + * 指定されたメソッドの戻り値型として宣言されているパラメタ化されたコレクションの要素型を取得する。 + * + * @param method メソッド + * @return 指定されたメソッドの戻り値型として宣言されているパラメタ化されたコレクションの要素型 + * @throws InvocationTargetException メソッドが例外をスローする場合 + * @throws IllegalAccessException メソッドにアクセスできない場合 + * @throws IllegalArgumentException 引数が正しくない場合 + */ + public static Class<?> getElementTypeOfCollectionFromReturnType(final Method method) + throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { + return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_COLLECTION_FROM_RETURN_METHOD, null, new Object[] { + method + }); + } + + /** + * メソッドの引数型 (パラメタ化されたリスト) の要素型を取得する。 + * + * @param method メソッド + * @param position パラメタ化されたリストが宣言されているメソッド引数の位置 + * @return 指定されたメソッドの引数型として宣言されているパラメタ化されたリストの要素型 + * @throws InvocationTargetException メソッドが例外をスローする場合 + * @throws IllegalAccessException メソッドにアクセスできない場合 + * @throws IllegalArgumentException 引数が正しくない場合 + */ + public static Class<?> getElementTypeOfListFromParameterType(final Method method, final int position) + throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { + return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_LIST_FROM_PARAMETER_METHOD, null, new Object[] { + method, + Integer.valueOf(position) + }); + } + + /** + * 指定されたメソッドの戻り値型として宣言されているパラメタ化されたリストの要素型を取得する。 + * + * @param method メソッド + * @return 指定されたメソッドの戻り値型として宣言されているパラメタ化されたリストの要素型 + * @throws InvocationTargetException メソッドが例外をスローする場合 + * @throws IllegalAccessException メソッドにアクセスできない場合 + * @throws IllegalArgumentException 引数が正しくない場合 + */ + public static Class<?> getElementTypeOfListFromReturnType(final Method method) throws IllegalArgumentException, + IllegalAccessException, InvocationTargetException { + return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_LIST_FROM_RETURN_METHOD, null, new Object[] { + method + }); + } + + /** + * メソッドの引数型 (パラメタ化されたセット) の要素型を取得する。 + * + * @param method メソッド + * @param position パラメタ化されたコレクションが宣言されているメソッド引数の位置 + * @return 指定されたメソッドの引数型として宣言されているパラメタ化されたセットの要素型 + * @throws InvocationTargetException メソッドが例外をスローする場合 + * @throws IllegalAccessException メソッドにアクセスできない場合 + * @throws IllegalArgumentException 引数が正しくない場合 + */ + public static Class<?> getElementTypeOfSetFromParameterType(final Method method, final int position) + throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { + return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_SET_FROM_PARAMETER_METHOD, null, new Object[] { + method, + Integer.valueOf(position) + }); + } + + /** + * 指定されたメソッドの戻り値型として宣言されているパラメタ化されたセットの要素型を取得する。 + * + * @param method メソッド + * @return 指定されたメソッドの戻り値型として宣言されているパラメタ化されたセットの要素型 + * @throws InvocationTargetException メソッドが例外をスローする場合 + * @throws IllegalAccessException メソッドにアクセスできない場合 + * @throws IllegalArgumentException 引数が正しくない場合 + */ + public static Class<?> getElementTypeOfSetFromReturnType(final Method method) throws IllegalArgumentException, + IllegalAccessException, InvocationTargetException { + if (GET_ELEMENT_TYPE_OF_SET_FROM_RETURN_METHOD == null) { + return null; + } + return (Class<?>) MethodUtil.invoke(GET_ELEMENT_TYPE_OF_SET_FROM_RETURN_METHOD, null, new Object[] { + method + }); + } + + private static Method getIsBridgeMethod() { + try { + return Method.class.getMethod("isBridge", new Class<?>[] { + null + }); + } catch (final NoSuchMethodException e) { + return null; + } + } + + private static Method getIsSyntheticMethod() { + try { + return Method.class.getMethod("isSynthetic", new Class<?>[] { + null + }); + } catch (final NoSuchMethodException e) { + return null; + } + } + + /** + * シグニチャを取得する。 + * + * @param methodName メソッド名 + * @param argTypes 引数 + * @return シグニチャ + */ + public static String getSignature(String methodName, Class<?>[] argTypes) { + StringBuffer buf = new StringBuffer(BUFF_SIZE); + buf.append(methodName); + buf.append("("); + if (argTypes != null) { + for (int i = 0; i < argTypes.length; ++i) { + if (i > 0) { + buf.append(", "); + } + buf.append(argTypes[i].getName()); + } + } + buf.append(")"); + return buf.toString(); + } + + /** + * シグニチャを取得する。 + * + * @param methodName メソッド名 + * @param methodArgs メソッドの引数 + * @return シグニチャ + */ + public static String getSignature(String methodName, Object[] methodArgs) { + StringBuffer buf = new StringBuffer(BUFF_SIZE); + buf.append(methodName); + buf.append("("); + if (methodArgs != null) { + for (int i = 0; i < methodArgs.length; ++i) { + if (i > 0) { + buf.append(", "); + } + if (methodArgs[i] != null) { + buf.append(methodArgs[i].getClass().getName()); + } else { + buf.append("null"); + } + } + } + buf.append(")"); + return buf.toString(); + } + + /** + * {@link Method#invoke(Object, Object[])}の例外処理をラップする。 + * + * @param method メソッド + * @param target ターゲット + * @param args 引数 + * @return 戻り値 + * @throws IllegalAccessException メソッドにアクセスできない場合 + * @throws IllegalArgumentException 引数が正しくない場合 + * @throws InvocationTargetException メソッドが例外をスローする場合 + * @see Method#invoke(Object, Object[]) + */ + public static Object invoke(Method method, Object target, Object[] args) throws IllegalArgumentException, + IllegalAccessException, InvocationTargetException { + try { + return method.invoke(target, args); + } catch (InvocationTargetException ex) { + Throwable t = ex.getCause(); + if (t instanceof RuntimeException) { + throw (RuntimeException) t; + } + if (t instanceof Error) { + throw (Error) t; + } + throw ex; + } + } + + /** + * <code>abstract</code>かどうかを取得する。 + * + * @param method メソッド + * @return <code>abstract</code>かどうか + */ + public static boolean isAbstract(Method method) { + int mod = method.getModifiers(); + return Modifier.isAbstract(mod); + } + + /** + * ブリッジメソッドかどうか取得する。 + * + * @param method {@link Method} + * @return ブリッジメソッドかどうか + * @throws InvocationTargetException メソッドが例外をスローする場合 + * @throws IllegalAccessException メソッドにアクセス場合 + * @throws IllegalArgumentException 引数が正しくない場合 + */ + public static boolean isBridgeMethod(final Method method) throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException { + if (IS_BRIDGE_METHOD == null) { + return false; + } + return ((Boolean) MethodUtil.invoke(IS_BRIDGE_METHOD, method, null)).booleanValue(); + } + + /** + * equalsメソッドかどうかを取得する。 + * + * @param method {@link Method} + * @return equalsメソッドかどうか + */ + public static boolean isEqualsMethod(Method method) { + return method != null && method.getName().equals("equals") && method.getReturnType() == boolean.class + && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class; + } + + /** + * hashCodeメソッドかどうか取得する。 + * + * @param method {@link Method} + * @return hashCodeメソッドかどうか + */ + public static boolean isHashCodeMethod(Method method) { + return method != null && method.getName().equals("hashCode") && method.getReturnType() == int.class + && method.getParameterTypes().length == 0; + } + + /** + * 合成メソッドかどうかを取得する。 + * + * @param method {@link Method} + * @return 合成メソッドかどうか + * @throws InvocationTargetException メソッドが例外をスローする場合 + * @throws IllegalAccessException メソッドにアクセス場合 + * @throws IllegalArgumentException 引数が正しくない場合 + */ + public static boolean isSyntheticMethod(final Method method) throws IllegalArgumentException, + IllegalAccessException, InvocationTargetException { + if (IS_SYNTHETIC_METHOD == null) { + return false; + } + return ((Boolean) MethodUtil.invoke(IS_SYNTHETIC_METHOD, method, null)).booleanValue(); + } + + /** + * toStringメソッドかどうか取得する。 + * + * @param method {@link Method} + * @return toStringメソッドかどうか + */ + public static boolean isToStringMethod(Method method) { + return method != null && method.getName().equals("toString") && method.getReturnType() == String.class + && method.getParameterTypes().length == 0; + } + + private MethodUtil() { + throw new JiemamyError("不到達ポイント"); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/MethodUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ModifierUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ModifierUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ModifierUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,171 +1,171 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; - -/** - * {@link Modifier}用のユーティリティクラスです。 - * - * @author j5ik2o - * - */ -public class ModifierUtil { - - static final int BRIDGE = 0x00000040; - - static final int SYNTHETIC = 0x00001000; - - - /** - * <code>abstract</code>かどうかを取得する。 - * - * @param clazz クラス - * @return <code>abstract</code>かどうか - */ - public static boolean isAbstract(Class<?> clazz) { - return isAbstract(clazz.getModifiers()); - } - - /** - * <code>abstract</code>かどうかを取得する。 - * - * @param modifier モディファイヤ - * @return <code>abstract</code>かどうか - */ - public static boolean isAbstract(int modifier) { - return Modifier.isAbstract(modifier); - } - - /** - * <code>final</code>かどうかを取得する。 - * - * @param modifier モディファイヤ - * @return <code>final</code>かどうか - */ - public static boolean isFinal(int modifier) { - return Modifier.isFinal(modifier); - } - - /** - * <code>final</code>かどうかを取得する。 - * - * @param method メソッド - * @return <code>final</code>かどうか - */ - public static boolean isFinal(Method method) { - return isFinal(method.getModifiers()); - } - - /** - * インスタンスフィールドかどうかを取得する。 - * - * @param field フィールド - * @return インスタンスフィールドかどうか - */ - public static boolean isInstanceField(Field field) { - int m = field.getModifiers(); - return !isStatic(m) && !isFinal(m); - } - - /** - * <code>public</code>かどうかを取得する。 - * - * @param f フィールド - * @return パブリックかどうか - */ - public static boolean isPublic(Field f) { - return isPublic(f.getModifiers()); - } - - /** - * <code>public</code>かどうかを取得する。 - * - * @param modifier モディファイヤ - * @return <code>public</code>かどうか - */ - public static boolean isPublic(int modifier) { - return Modifier.isPublic(modifier); - } - - /** - * <code>public</code>かどうかを取得する。 - * - * @param m メソッド - * @return パブリックかどうか - */ - public static boolean isPublic(Method m) { - return isPublic(m.getModifiers()); - } - - /** - * <code>public</code>,<code>static</code>,<code>final</code>かどうかを取得する。 - * - * @param modifier モディファイヤ - * @return <code>public</code>,<code>static</code>,<code>final</code>かどうか - */ - public static boolean isPublicStaticFinal(int modifier) { - return isPublic(modifier) && isStatic(modifier) && isFinal(modifier); - } - - /** - * <code>public</code>,<code>static</code>,<code>final</code>かどうかを取得する。 - * - * @param f フィールド - * @return <code>public</code>,<code>static</code>,<code>final</code>かどうか - */ - public static boolean isPublicStaticFinalField(Field f) { - return isPublicStaticFinal(f.getModifiers()); - } - - /** - * <code>static</code>かどうかを取得する。 - * - * @param modifier モディファイヤ - * @return <code>static</code>かどうか - */ - public static boolean isStatic(int modifier) { - return Modifier.isStatic(modifier); - } - - /** - * <code>transient</code>かどうかを取得する。 - * - * @param field フィールド - * @return <code>transient</code>かどうか - * @see #isTransient(int) - */ - public static boolean isTransient(Field field) { - return isTransient(field.getModifiers()); - } - - /** - * <code>transient</code>かどうかを取得する。 - * - * @param modifier モディファイヤ - * @return <code>transient</code>かどうか - */ - public static boolean isTransient(int modifier) { - return Modifier.isTransient(modifier); - } - - private ModifierUtil() { - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +/** + * {@link Modifier}用のユーティリティクラスです。 + * + * @author j5ik2o + * + */ +public class ModifierUtil { + + static final int BRIDGE = 0x00000040; + + static final int SYNTHETIC = 0x00001000; + + + /** + * <code>abstract</code>かどうかを取得する。 + * + * @param clazz クラス + * @return <code>abstract</code>かどうか + */ + public static boolean isAbstract(Class<?> clazz) { + return isAbstract(clazz.getModifiers()); + } + + /** + * <code>abstract</code>かどうかを取得する。 + * + * @param modifier モディファイヤ + * @return <code>abstract</code>かどうか + */ + public static boolean isAbstract(int modifier) { + return Modifier.isAbstract(modifier); + } + + /** + * <code>final</code>かどうかを取得する。 + * + * @param modifier モディファイヤ + * @return <code>final</code>かどうか + */ + public static boolean isFinal(int modifier) { + return Modifier.isFinal(modifier); + } + + /** + * <code>final</code>かどうかを取得する。 + * + * @param method メソッド + * @return <code>final</code>かどうか + */ + public static boolean isFinal(Method method) { + return isFinal(method.getModifiers()); + } + + /** + * インスタンスフィールドかどうかを取得する。 + * + * @param field フィールド + * @return インスタンスフィールドかどうか + */ + public static boolean isInstanceField(Field field) { + int m = field.getModifiers(); + return !isStatic(m) && !isFinal(m); + } + + /** + * <code>public</code>かどうかを取得する。 + * + * @param f フィールド + * @return パブリックかどうか + */ + public static boolean isPublic(Field f) { + return isPublic(f.getModifiers()); + } + + /** + * <code>public</code>かどうかを取得する。 + * + * @param modifier モディファイヤ + * @return <code>public</code>かどうか + */ + public static boolean isPublic(int modifier) { + return Modifier.isPublic(modifier); + } + + /** + * <code>public</code>かどうかを取得する。 + * + * @param m メソッド + * @return パブリックかどうか + */ + public static boolean isPublic(Method m) { + return isPublic(m.getModifiers()); + } + + /** + * <code>public</code>,<code>static</code>,<code>final</code>かどうかを取得する。 + * + * @param modifier モディファイヤ + * @return <code>public</code>,<code>static</code>,<code>final</code>かどうか + */ + public static boolean isPublicStaticFinal(int modifier) { + return isPublic(modifier) && isStatic(modifier) && isFinal(modifier); + } + + /** + * <code>public</code>,<code>static</code>,<code>final</code>かどうかを取得する。 + * + * @param f フィールド + * @return <code>public</code>,<code>static</code>,<code>final</code>かどうか + */ + public static boolean isPublicStaticFinalField(Field f) { + return isPublicStaticFinal(f.getModifiers()); + } + + /** + * <code>static</code>かどうかを取得する。 + * + * @param modifier モディファイヤ + * @return <code>static</code>かどうか + */ + public static boolean isStatic(int modifier) { + return Modifier.isStatic(modifier); + } + + /** + * <code>transient</code>かどうかを取得する。 + * + * @param field フィールド + * @return <code>transient</code>かどうか + * @see #isTransient(int) + */ + public static boolean isTransient(Field field) { + return isTransient(field.getModifiers()); + } + + /** + * <code>transient</code>かどうかを取得する。 + * + * @param modifier モディファイヤ + * @return <code>transient</code>かどうか + */ + public static boolean isTransient(int modifier) { + return Modifier.isTransient(modifier); + } + + private ModifierUtil() { + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ModifierUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/OutputStreamUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/OutputStreamUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/OutputStreamUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,61 +1,61 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.IOException; -import java.io.OutputStream; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link OutputStream}用のユーティリティクラス。 - * - * @author j5ik2o - */ -public final class OutputStreamUtil { - - /** - * {@link OutputStream}を閉じる。 - * - * @param out {@link OutputStream} - * @throws IOException closeが失敗した場合 - */ - public static void close(OutputStream out) throws IOException { - if (out == null) { - return; - } - out.close(); - } - - /** - * {@link OutputStream}をフラッシュする。 - * - * @param out {@link OutputStream} - * @throws IOException closeが失敗した場合 - */ - public static void flush(OutputStream out) throws IOException { - if (out == null) { - return; - } - out.flush(); - } - - private OutputStreamUtil() { - throw new JiemamyError("不到達ポイント"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.IOException; +import java.io.OutputStream; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link OutputStream}用のユーティリティクラス。 + * + * @author j5ik2o + */ +public final class OutputStreamUtil { + + /** + * {@link OutputStream}を閉じる。 + * + * @param out {@link OutputStream} + * @throws IOException closeが失敗した場合 + */ + public static void close(OutputStream out) throws IOException { + if (out == null) { + return; + } + out.close(); + } + + /** + * {@link OutputStream}をフラッシュする。 + * + * @param out {@link OutputStream} + * @throws IOException closeが失敗した場合 + */ + public static void flush(OutputStream out) throws IOException { + if (out == null) { + return; + } + out.flush(); + } + + private OutputStreamUtil() { + throw new JiemamyError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/OutputStreamUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/PropertyNotFoundException.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/PropertyNotFoundException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/PropertyNotFoundException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,74 +1,74 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -/** - * プロパティが見つからない場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class PropertyNotFoundException extends Exception { - - private String entityName; - - private String propertyName; - - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - */ - public PropertyNotFoundException(String entityName, String propertyName) { - this(entityName, propertyName, null); - } - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - * @param cause 原因となった例外 - */ - public PropertyNotFoundException(String entityName, String propertyName, Throwable cause) { - super(String.format("%s.%s is not found.", entityName, propertyName), cause); - this.entityName = entityName; - this.propertyName = propertyName; - } - - /** - * エンティティ名を取得する。 - * - * @return エンティティ名 - */ - public String getEntityName() { - return entityName; - } - - /** - * プロパティ名を取得する。 - * - * @return プロパティ名 - */ - public String getPropertyName() { - return propertyName; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +/** + * プロパティが見つからない場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class PropertyNotFoundException extends Exception { + + private String entityName; + + private String propertyName; + + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + */ + public PropertyNotFoundException(String entityName, String propertyName) { + this(entityName, propertyName, null); + } + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + * @param cause 原因となった例外 + */ + public PropertyNotFoundException(String entityName, String propertyName, Throwable cause) { + super(String.format("%s.%s is not found.", entityName, propertyName), cause); + this.entityName = entityName; + this.propertyName = propertyName; + } + + /** + * エンティティ名を取得する。 + * + * @return エンティティ名 + */ + public String getEntityName() { + return entityName; + } + + /** + * プロパティ名を取得する。 + * + * @return プロパティ名 + */ + public String getPropertyName() { + return propertyName; + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/PropertyNotFoundException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ReflectionUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ReflectionUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ReflectionUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,622 +1,622 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/29 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Type; - -import org.apache.commons.lang.CharUtils; - -/** - * リフレクションを使用するユーティリティクラス。 - * - * @author daisuke - */ -public class ReflectionUtil { - - /** setterの接頭句 */ - public static final String SET = "set"; - - /** getterの接頭句 */ - public static final String GET = "get"; - - /** boolean getterの接頭句 */ - public static final String IS = "is"; - - - /** - * アクセサメソッドから、フィールド名を割り出す。 - * - * @param method アクセサメソッド - * @return フィールド名 - * @throws IllegalArgumentException メソッドがアクセサではない場合 - */ - public static String convertAccessorToFieldName(Method method) { - if (isAccessor(method) == false) { - throw new IllegalArgumentException(); - } - Class<?> returnType = method.getReturnType(); - String name = method.getName(); - if ((returnType == boolean.class || returnType == Boolean.class) && name.startsWith(IS)) { - return JmStringUtil.toUnCapital(name.substring(2)); - } - return JmStringUtil.toUnCapital(name.substring(3)); - } - - /** - * フィールド名からアクセサ名を割り出す。 - * - * @param fieldName フィールド名 - * @param prefix 接頭辞("set", "get", "is" 等) - * @return アクセサ名 - */ - public static String convertFieldNameToAccessorName(String fieldName, String prefix) { - return prefix + JmStringUtil.toCapital(fieldName); - } - - /** - * フィールド名からsetter名を割り出す。 - * - * @param fieldName フィールド名 - * @return setter名 - */ - public static String convertFieldNameToSetterName(String fieldName) { - return convertFieldNameToAccessorName(fieldName, SET); - } - - /** - * フィールドからアクセサ名を割り出す。 - * - * @param field フィールド - * @param prefix 接頭辞("set", "get", "is" 等) - * @return アクセサ名 - */ - public static String convertFieldToAccessorName(Field field, String prefix) { - return convertFieldNameToAccessorName(field.getName(), prefix); - } - - /** - * フィールドからgetter名を割り出す。 - * - * @param field フィールド - * @return getter名 - */ - public static String convertFieldToGetterName(Field field) { - if (field.getType() == boolean.class || field.getType() == Boolean.class) { - return convertFieldToAccessorName(field, IS); - } - return convertFieldToAccessorName(field, GET); - } - - /** - * フィールドからsetter名を割り出す。 - * - * @param field フィールド - * @return setter名 - */ - public static String convertFieldToSetterName(Field field) { - return convertFieldToAccessorName(field, SET); - } - - /** - * 現在のスレッドのコンテキストクラスローダを使って指定された文字列名を持つクラスまたはインタフェースに - * 関連付けられた{@link Class}オブジェクトを取得する。 - * - * @param <T> {@link Class}オブジェクトが表すクラス - * @param className 要求するクラスの完全修飾名 - * @return 指定された名前を持つクラスの{@link Class}オブジェクト - * @throws ClassNotFoundException クラスが見つからなかった場合 - * @see Class#forName(String) - */ - public static <T>Class<T> forName(final String className) throws ClassNotFoundException { - return forName(className, Thread.currentThread().getContextClassLoader()); - } - - /** - * 指定されたクラスローダを使って指定された文字列名を持つクラスまたはインタフェースに - * 関連付けられた{@link Class}オブジェクトを取得する。 - * - * @param <T> {@link Class}オブジェクトが表すクラス - * @param className 要求するクラスの完全修飾名 - * @param loader クラスのロード元である必要があるクラスローダ - * @return 指定された名前を持つクラスの{@link Class}オブジェクト - * @throws ClassNotFoundException クラスが見つからなかった場合 - * @see Class#forName(String, boolean, ClassLoader) - */ - @SuppressWarnings("unchecked") - public static <T>Class<T> forName(final String className, final ClassLoader loader) throws ClassNotFoundException { - return (Class<T>) Class.forName(className, true, loader); - } - - /** - * 現在のスレッドのコンテキストクラスローダを使って、 指定された文字列名を持つクラスまたはインタフェースに - * 関連付けられた{@link Class}オブジェクトを取得する。 - * <p> - * クラスが見つからなかった場合は{@code null}を取得する。 - * </p> - * - * @param <T> {@link Class}オブジェクトが表すクラス - * @param className 要求するクラスの完全修飾名 - * @return 指定された名前を持つクラスの{@link Class}オブジェクト - * @see Class#forName(String) - */ - public static <T>Class<T> forNameNoException(final String className) { - return forNameNoException(className, Thread.currentThread().getContextClassLoader()); - } - - /** - * 指定されたクラスローダを使って、 指定された文字列名を持つクラスまたはインタフェースに - * 関連付けられた{@link Class}オブジェクトを取得する。 - * <p> - * クラスが見つからなかった場合は{@code null}を取得する。 - * </p> - * - * @param <T> {@link Class}オブジェクトが表すクラス - * @param className 要求するクラスの完全修飾名 - * @param loader クラスのロード元である必要があるクラスローダ - * @return 指定された名前を持つクラスの{@link Class}オブジェクト - * @see Class#forName(String) - */ - @SuppressWarnings("unchecked") - public static <T>Class<T> forNameNoException(final String className, final ClassLoader loader) { - try { - return (Class<T>) Class.forName(className, true, loader); - } catch (final Throwable ignore) { - return null; - } - } - - /** - * {@link Class}オブジェクトが表すクラスの指定された{@code public}コンストラクタを - * リフレクトする{@link Constructor}オブジェクトを取得する。 - * - * @param <T> {@link Class}オブジェクトが表すクラス - * @param clazz クラスの{@link Class}オブジェクト - * @param argTypes パラメータ配列 - * @return 指定された{@code argTypes}と一致する{@code public}コンストラクタの{@link Constructor}オブジェクト - * @throws NoSuchMethodException メソッドが見つからなかった場合 - * @throws SecurityException セキュリティ違反が発生した場合 - * @see Class#getConstructor(Class[]) - */ - public static <T>Constructor<T> getConstructor(final Class<T> clazz, final Class<?>... argTypes) - throws SecurityException, NoSuchMethodException { - return clazz.getConstructor(argTypes); - } - - /** - * {@link Class}オブジェクトが表すクラスまたはインタフェースの指定されたコンストラクタを - * リフレクトする{@link Constructor}オブジェクトを取得する。 - * - * @param <T> {@link Class}オブジェクトが表すクラス - * @param clazz クラスの{@link Class}オブジェクト - * @param argTypes パラメータ配列 - * @return 指定された{@code argTypes}と一致するコンストラクタの{@link Constructor}オブジェクト - * @throws NoSuchMethodException メソッドが見つからなかった場合 - * @throws SecurityException セキュリティ違反が発生した場合 - * @see Class#getDeclaredConstructor(Class[]) - */ - public static <T>Constructor<T> getDeclaredConstructor(final Class<T> clazz, final Class<?>... argTypes) - throws SecurityException, NoSuchMethodException { - return clazz.getDeclaredConstructor(argTypes); - } - - /** - * {@link Class}オブジェクトが表すクラスまたはインタフェースの指定された宣言フィールドをリフレクトする - * {@link Field}オブジェクトを取得する。 - * - * @param clazz クラスの{@link Class}オブジェクト - * @param name フィールド名 - * @return {@code name}で指定されたこのクラスの{@link Field}オブジェクト - * @throws NoSuchFieldException メソッドが見つからなかった場合 - * @throws SecurityException セキュリティ違反が発生した場合 - * @see Class#getDeclaredField(String) - */ - public static Field getDeclaredField(final Class<?> clazz, final String name) throws SecurityException, - NoSuchFieldException { - return clazz.getDeclaredField(name); - } - - /** - * {@link Class}オブジェクトが表すクラスまたはインタフェースの指定された宣言フィールドをリフレクトする - * {@link Field}オブジェクトを取得する。ただし例外をスローしない。 - * - * @param clazz クラスの{@link Class}オブジェクト - * @param name フィールド名 - * @return {@code name}で指定されたこのクラスの{@link Field}オブジェクト. 例外が発生した場合は{@code null} - * @see Class#getDeclaredField(String) - */ - public static Field getDeclaredFieldNoException(final Class<?> clazz, final String name) { - try { - return clazz.getDeclaredField(name); - } catch (SecurityException e) { - return null; - } catch (NoSuchFieldException e) { - return null; - } - } - - /** - * {@link Class}オブジェクトが表すクラスまたはインタフェースの指定されたメンバメソッドを - * リフレクトする{@link Method}オブジェクトを取得する。 - * - * @param clazz クラスの{@link Class}オブジェクト - * @param name メソッドの名前 - * @param argTypes パラメータのリスト - * @return 指定された{@code name}および{@code argTypes}と一致する{@link Method}オブジェクト - * @throws NoSuchMethodException メソッドが見つからない場合 - * @throws SecurityException セキュリティ違反が発生した場合 - * @see Class#getDeclaredMethod(String, Class[]) - */ - public static Method getDeclaredMethod(final Class<?> clazz, final String name, final Class<?>... argTypes) - throws SecurityException, NoSuchMethodException { - return clazz.getDeclaredMethod(name, argTypes); - } - - /** - * パラメタ化されたコレクションの要素型を取得する。 - * - * @param parameterizedCollection パラメタ化されたコレクションの型 - * @return パラメタ化されたコレクションの要素型 - */ - public static Class<?> getElementTypeOfCollection(final Type parameterizedCollection) { - return GenericUtil.getRawClass(GenericUtil.getElementTypeOfCollection(parameterizedCollection)); - } - - /** - * 指定されたフィールドのパラメタ化されたコレクションの要素型を取得する。 - * - * @param field フィールド - * @return 指定されたフィールドのパラメタ化されたコレクションの要素型 since 2.4.18 - * since 2.4.18 - */ - public static Class<?> getElementTypeOfCollectionFromFieldType(final Field field) { - final Type type = field.getGenericType(); - return getElementTypeOfCollection(type); - } - - /** - * 指定されたメソッドの引数型として宣言されているパラメタ化されたコレクションの要素型を取得する。 - * - * @param method メソッド - * @param parameterPosition パラメタ化されたコレクションが宣言されているメソッド引数の位置 - * @return 指定されたメソッドの引数型として宣言されているパラメタ化されたコレクションの要素型 - */ - public static Class<?> getElementTypeOfCollectionFromParameterType(final Method method, final int parameterPosition) { - final Type[] parameterTypes = method.getGenericParameterTypes(); - return getElementTypeOfCollection(parameterTypes[parameterPosition]); - } - - /** - * 指定されたメソッドの戻り値型として宣言されているパラメタ化されたコレクションの要素型を取得する。 - * - * @param method メソッド - * @return 指定されたメソッドの戻り値型として宣言されているパラメタ化されたコレクションの要素型 - */ - public static Class<?> getElementTypeOfCollectionFromReturnType(final Method method) { - return getElementTypeOfCollection(method.getGenericReturnType()); - } - - /** - * パラメタ化されたリストの要素型を取得する。 - * - * @param parameterizedList パラメタ化されたリストの型 - * @return パラメタ化されたリストの要素型 - */ - public static Class<?> getElementTypeOfList(final Type parameterizedList) { - return GenericUtil.getRawClass(GenericUtil.getElementTypeOfList(parameterizedList)); - } - - /** - * 指定されたフィールドのパラメタ化されたリストの要素型を取得する。 - * - * @param field フィールド - * @return 指定されたフィールドのパラメタ化されたリストの要素型 - */ - public static Class<?> getElementTypeOfListFromFieldType(final Field field) { - final Type type = field.getGenericType(); - return getElementTypeOfList(type); - } - - /** - * 指定されたメソッドの引数型として宣言されているパラメタ化されたリストの要素型を取得する。 - * - * @param method メソッド - * @param parameterPosition パラメタ化されたリストが宣言されているメソッド引数の位置 - * @return 指定されたメソッドの引数型として宣言されているパラメタ化されたリストの要素型 - */ - public static Class<?> getElementTypeOfListFromParameterType(final Method method, final int parameterPosition) { - final Type[] parameterTypes = method.getGenericParameterTypes(); - return getElementTypeOfList(parameterTypes[parameterPosition]); - } - - /** - * 指定されたメソッドの戻り値型として宣言されているパラメタ化されたリストの要素型を取得する。 - * - * @param method メソッド - * @return 指定されたメソッドの戻り値型として宣言されているパラメタ化されたリストの要素型 - */ - public static Class<?> getElementTypeOfListFromReturnType(final Method method) { - return getElementTypeOfList(method.getGenericReturnType()); - } - - /** - * パラメタ化されたセットの要素型を取得する。 - * - * @param parameterizedSet パラメタ化されたセットの型 - * @return パラメタ化されたセットの要素型 - */ - public static Class<?> getElementTypeOfSet(final Type parameterizedSet) { - return GenericUtil.getRawClass(GenericUtil.getElementTypeOfSet(parameterizedSet)); - } - - /** - * 指定されたフィールドのパラメタ化されたセットの要素型を取得する。 - * - * @param field フィールド - * @return 指定されたフィールドのパラメタ化されたセットの要素型 since 2.4.18 - */ - public static Class<?> getElementTypeOfSetFromFieldType(final Field field) { - final Type type = field.getGenericType(); - return getElementTypeOfSet(type); - } - - /** - * 指定されたメソッドの引数型として宣言されているパラメタ化されたセットの要素型を取得する。 - * - * @param method メソッド - * @param parameterPosition パラメタ化されたセットが宣言されているメソッド引数の位置 - * @return 指定されたメソッドの引数型として宣言されているパラメタ化されたセットの要素型 - */ - public static Class<?> getElementTypeOfSetFromParameterType(final Method method, final int parameterPosition) { - final Type[] parameterTypes = method.getGenericParameterTypes(); - return getElementTypeOfSet(parameterTypes[parameterPosition]); - } - - /** - * 指定されたメソッドの戻り値型として宣言されているパラメタ化されたセットの要素型を取得する。 - * - * @param method メソッド - * @return 指定されたメソッドの戻り値型として宣言されているパラメタ化されたセットの要素型 - */ - public static Class<?> getElementTypeOfSetFromReturnType(final Method method) { - return getElementTypeOfSet(method.getGenericReturnType()); - } - - /** - * {@link Class}オブジェクトが表すクラスまたはインタフェースの指定された{@code public}メンバフィールドをリフレクトする{@link Field}オブジェクトを取得する。 - * - * @param clazz クラスの{@link Class}オブジェクト - * @param name フィールド名 - * @return {@code name}で指定されたこのクラスの{@link Field}オブジェクト - * @throws NoSuchFieldException フィールドが見つからなかった場合 - * @throws SecurityException セキュリティ違反が発生した場合 - * @see Class#getField(String) - */ - public static Field getField(final Class<?> clazz, final String name) throws SecurityException, - NoSuchFieldException { - return clazz.getField(name); - } - - /** - * {@link Class}オブジェクトが表すクラスまたはインタフェースの指定された{@code public}メンバメソッドを - * リフレクトする{@link Method}オブジェクトを取得する。 - * - * @param clazz クラスの{@link Class}オブジェクト - * @param name メソッドの名前 - * @param argTypes パラメータのリスト - * @return 指定された{@code name}および{@code argTypes}と一致する{@link Method}オブジェクト - * @throws NoSuchMethodException メソッドが見つからなかった場合 - * @throws SecurityException セキュリティ違反が発生した場合 - * @see Class#getMethod(String, Class[]) - */ - public static Method getMethod(final Class<?> clazz, final String name, final Class<?>... argTypes) - throws SecurityException, NoSuchMethodException { - return clazz.getMethod(name, argTypes); - } - - /** - * 指定されたオブジェクトについて、{@link Field}によって表される{@code static}フィールドの値を取得する。 - * - * @param <T> フィールドの型 - * @param field フィールド - * @return {@code static}フィールドで表現される値 - * @throws IllegalAccessException 基本となるフィールドにアクセスできない場合 - * @see Field#get(Object) - */ - @SuppressWarnings("unchecked") - public static <T>T getStaticValue(final Field field) throws IllegalAccessException { - return (T) getValue(field, null); - } - - /** - * 指定されたオブジェクトについて、{@link Field}によって表されるフィールドの値を取得する。 - * - * @param <T> フィールドの型 - * @param field フィールド - * @param target 表現されるフィールド値の抽出元オブジェクト - * @return オブジェクト{@code obj}内で表現される値 - * @throws IllegalAccessException 基本となるフィールドにアクセスできない場合 - * @see Field#get(Object) - */ - @SuppressWarnings("unchecked") - public static <T>T getValue(final Field field, final Object target) throws IllegalAccessException { - return (T) field.get(target); - } - - /** - * {@link Method}オブジェクトによって表される基本となるメソッドを、指定したオブジェクトに対して指定したパラメータで呼び出す。 - * - * @param <T> メソッドの戻り値の型 - * @param method メソッド - * @param target 基本となるメソッドの呼び出し元のオブジェクト - * @param args メソッド呼び出しに使用される引数 - * @return このオブジェクトが表すメソッドを、パラメータ{@code args}を使用して{@code obj}にディスパッチした結果 - * @throws InvocationTargetException 基本となるメソッドが例外をスローする場合 - * @throws IllegalAccessException この{@link Method}オブジェクトがJava言語アクセス制御を実施し基本となるメソッドにアクセスできない場合 - * @throws IllegalArgumentException 不正な引数、または不適切な引数をメソッドに渡した場合 - * @see Method#invoke(Object, Object[]) - */ - @SuppressWarnings("unchecked") - public static <T>T invoke(final Method method, final Object target, final Object... args) - throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { - return (T) method.invoke(target, args); - } - - /** - * {@link Method}オブジェクトによって表される基本となる{@code static}メソッドを指定したパラメータで呼び出す。 - * - * @param <T> メソッドの戻り値の型 - * @param method メソッド - * @param args メソッド呼び出しに使用される引数 - * @return このオブジェクトが表す{@code static}メソッドを、パラメータ{@code args}を使用してディスパッチした結果 - * @throws InvocationTargetException 基本となるメソッドが例外をスローする場合 - * @throws IllegalAccessException この{@link Method}オブジェクトがJava言語アクセス制御を実施し基本となるメソッドにアクセスできない場合 - * @throws IllegalArgumentException 不正な引数、または不適切な引数をメソッドに渡した場合 - * @see Method#invoke(Object, Object[]) - */ - @SuppressWarnings("unchecked") - public static <T>T invokeStatic(final Method method, final Object... args) throws IllegalArgumentException, - IllegalAccessException, InvocationTargetException { - return (T) invoke(method, null, args); - } - - /** - * メソッドがアクセサメソッドかどうかを調べる。 - * - * @param method メソッド - * @return アクセサであれば{@code true} - */ - public static boolean isAccessor(Method method) { - return isGetter(method) || isSetter(method); - } - - /** - * メソッドがgetterかどうか調べる。 - * - * @param method メソッド - * @return getterであれば{@code true} - */ - public static boolean isGetter(Method method) { - Class<?>[] parameterTypes = method.getParameterTypes(); - if (parameterTypes.length != 0) { - return false; - } - Class<?> returnType = method.getReturnType(); - String name = method.getName(); - if (returnType == void.class || returnType == Void.class) { - return false; - } else if (returnType == boolean.class || returnType == Boolean.class) { - boolean result = - name.startsWith(IS) && name.length() > 2 && CharUtils.isAsciiAlphaUpper(name.toCharArray()[2]); - if (result == true) { - return true; - } - } - return name.startsWith(GET) && name.length() > 3 && CharUtils.isAsciiAlphaUpper(name.toCharArray()[3]); - } - - /** - * メソッドがsetterかどうか調べる。 - * - * @param method メソッド - * @return setterであれば{@code true} - */ - public static boolean isSetter(Method method) { - Class<?>[] parameterTypes = method.getParameterTypes(); - if (parameterTypes.length != 1) { - return false; - } - Class<?> returnType = method.getReturnType(); - if (returnType != void.class && returnType != Void.class) { - return false; - } - String name = method.getName(); - return name.startsWith(SET) && name.length() > 3 && CharUtils.isAsciiAlphaUpper(name.toCharArray()[3]); - } - - /** - * 指定されたクラスのデフォルトコンストラクタで、クラスの新しいインスタンスを作成および初期化する。 - * - * @param <T> {@link Class}オブジェクトが表すクラス - * @param clazz クラスを表す{@link Class}オブジェクト - * @return このオブジェクトが表すコンストラクタを呼び出すことで作成される新規オブジェクト - * @throws InstantiationException 基本となるコンストラクタを宣言するクラスが{@code abstract}クラスを表す場合 - * @throws IllegalAccessException 実パラメータ数と仮パラメータ数が異なる場合、 - * プリミティブ引数のラップ解除変換が失敗した場合、 またはラップ解除後、 - * メソッド呼び出し変換によってパラメータ値を対応する仮パラメータ型に変換できない場合、 - * このコンストラクタが列挙型に関連している場合 - * @see Constructor#newInstance(Object[]) - */ - public static <T>T newInstance(final Class<T> clazz) throws InstantiationException, IllegalAccessException { - return clazz.newInstance(); - } - - /** - * 指定された初期化パラメータで、コンストラクタの宣言クラスの新しいインスタンスを作成および初期化する。 - * - * @param <T> コンストラクタの宣言クラス - * @param constructor コンストラクタ - * @param args コンストラクタ呼び出しに引数として渡すオブジェクトの配列 - * @return コンストラクタを呼び出すことで作成される新規オブジェクト - * @throws InstantiationException 基本となるコンストラクタを宣言するクラスが{@code abstract}クラスを表す場合 - * @throws IllegalAccessException 実パラメータ数と仮パラメータ数が異なる場合、 - * プリミティブ引数のラップ解除変換が失敗した場合、 またはラップ解除後、 - * メソッド呼び出し変換によってパラメータ値を対応する仮パラメータ型に変換できない場合、 - * このコンストラクタが列挙型に関連している場合 - * @throws InvocationTargetException 基本となるメソッドが例外をスローする場合 - * @throws IllegalArgumentException 不正な引数、または不適切な引数をメソッドに渡した場合 - * @see Constructor#newInstance(Object[]) - */ - public static <T>T newInstance(final Constructor<T> constructor, final Object... args) - throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - return constructor.newInstance(args); - } - - /** - * {@link Field}オブジェクトによって表される{@code static}フィールドを、指定された新しい値に設定する。 - * - * @param field フィールド - * @param value {@code static}フィールドの新しい値 - * @throws IllegalAccessException 基本となるフィールドにアクセスできない場合 - * @see Field#set(Object, Object) - */ - public static void setStaticValue(final Field field, final Object value) throws IllegalAccessException { - setValue(field, null, value); - } - - /** - * {@link Field}オブジェクトによって表される指定されたオブジェクト引数のフィールドを、指定された新しい値に設定する。 - * - * @param field フィールド - * @param target フィールドを変更するオブジェクト - * @param value 変更中の{@code target}の新しいフィールド値 - * @throws IllegalAccessException 基本となるフィールドにアクセスできない場合 - * @see Field#set(Object, Object) - */ - public static void setValue(final Field field, final Object target, final Object value) - throws IllegalAccessException { - field.set(target, value); - } - - private ReflectionUtil() { - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/29 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Type; + +import org.apache.commons.lang.CharUtils; + +/** + * リフレクションを使用するユーティリティクラス。 + * + * @author daisuke + */ +public class ReflectionUtil { + + /** setterの接頭句 */ + public static final String SET = "set"; + + /** getterの接頭句 */ + public static final String GET = "get"; + + /** boolean getterの接頭句 */ + public static final String IS = "is"; + + + /** + * アクセサメソッドから、フィールド名を割り出す。 + * + * @param method アクセサメソッド + * @return フィールド名 + * @throws IllegalArgumentException メソッドがアクセサではない場合 + */ + public static String convertAccessorToFieldName(Method method) { + if (isAccessor(method) == false) { + throw new IllegalArgumentException(); + } + Class<?> returnType = method.getReturnType(); + String name = method.getName(); + if ((returnType == boolean.class || returnType == Boolean.class) && name.startsWith(IS)) { + return JmStringUtil.toUnCapital(name.substring(2)); + } + return JmStringUtil.toUnCapital(name.substring(3)); + } + + /** + * フィールド名からアクセサ名を割り出す。 + * + * @param fieldName フィールド名 + * @param prefix 接頭辞("set", "get", "is" 等) + * @return アクセサ名 + */ + public static String convertFieldNameToAccessorName(String fieldName, String prefix) { + return prefix + JmStringUtil.toCapital(fieldName); + } + + /** + * フィールド名からsetter名を割り出す。 + * + * @param fieldName フィールド名 + * @return setter名 + */ + public static String convertFieldNameToSetterName(String fieldName) { + return convertFieldNameToAccessorName(fieldName, SET); + } + + /** + * フィールドからアクセサ名を割り出す。 + * + * @param field フィールド + * @param prefix 接頭辞("set", "get", "is" 等) + * @return アクセサ名 + */ + public static String convertFieldToAccessorName(Field field, String prefix) { + return convertFieldNameToAccessorName(field.getName(), prefix); + } + + /** + * フィールドからgetter名を割り出す。 + * + * @param field フィールド + * @return getter名 + */ + public static String convertFieldToGetterName(Field field) { + if (field.getType() == boolean.class || field.getType() == Boolean.class) { + return convertFieldToAccessorName(field, IS); + } + return convertFieldToAccessorName(field, GET); + } + + /** + * フィールドからsetter名を割り出す。 + * + * @param field フィールド + * @return setter名 + */ + public static String convertFieldToSetterName(Field field) { + return convertFieldToAccessorName(field, SET); + } + + /** + * 現在のスレッドのコンテキストクラスローダを使って指定された文字列名を持つクラスまたはインタフェースに + * 関連付けられた{@link Class}オブジェクトを取得する。 + * + * @param <T> {@link Class}オブジェクトが表すクラス + * @param className 要求するクラスの完全修飾名 + * @return 指定された名前を持つクラスの{@link Class}オブジェクト + * @throws ClassNotFoundException クラスが見つからなかった場合 + * @see Class#forName(String) + */ + public static <T>Class<T> forName(final String className) throws ClassNotFoundException { + return forName(className, Thread.currentThread().getContextClassLoader()); + } + + /** + * 指定されたクラスローダを使って指定された文字列名を持つクラスまたはインタフェースに + * 関連付けられた{@link Class}オブジェクトを取得する。 + * + * @param <T> {@link Class}オブジェクトが表すクラス + * @param className 要求するクラスの完全修飾名 + * @param loader クラスのロード元である必要があるクラスローダ + * @return 指定された名前を持つクラスの{@link Class}オブジェクト + * @throws ClassNotFoundException クラスが見つからなかった場合 + * @see Class#forName(String, boolean, ClassLoader) + */ + @SuppressWarnings("unchecked") + public static <T>Class<T> forName(final String className, final ClassLoader loader) throws ClassNotFoundException { + return (Class<T>) Class.forName(className, true, loader); + } + + /** + * 現在のスレッドのコンテキストクラスローダを使って、 指定された文字列名を持つクラスまたはインタフェースに + * 関連付けられた{@link Class}オブジェクトを取得する。 + * <p> + * クラスが見つからなかった場合は{@code null}を取得する。 + * </p> + * + * @param <T> {@link Class}オブジェクトが表すクラス + * @param className 要求するクラスの完全修飾名 + * @return 指定された名前を持つクラスの{@link Class}オブジェクト + * @see Class#forName(String) + */ + public static <T>Class<T> forNameNoException(final String className) { + return forNameNoException(className, Thread.currentThread().getContextClassLoader()); + } + + /** + * 指定されたクラスローダを使って、 指定された文字列名を持つクラスまたはインタフェースに + * 関連付けられた{@link Class}オブジェクトを取得する。 + * <p> + * クラスが見つからなかった場合は{@code null}を取得する。 + * </p> + * + * @param <T> {@link Class}オブジェクトが表すクラス + * @param className 要求するクラスの完全修飾名 + * @param loader クラスのロード元である必要があるクラスローダ + * @return 指定された名前を持つクラスの{@link Class}オブジェクト + * @see Class#forName(String) + */ + @SuppressWarnings("unchecked") + public static <T>Class<T> forNameNoException(final String className, final ClassLoader loader) { + try { + return (Class<T>) Class.forName(className, true, loader); + } catch (final Throwable ignore) { + return null; + } + } + + /** + * {@link Class}オブジェクトが表すクラスの指定された{@code public}コンストラクタを + * リフレクトする{@link Constructor}オブジェクトを取得する。 + * + * @param <T> {@link Class}オブジェクトが表すクラス + * @param clazz クラスの{@link Class}オブジェクト + * @param argTypes パラメータ配列 + * @return 指定された{@code argTypes}と一致する{@code public}コンストラクタの{@link Constructor}オブジェクト + * @throws NoSuchMethodException メソッドが見つからなかった場合 + * @throws SecurityException セキュリティ違反が発生した場合 + * @see Class#getConstructor(Class[]) + */ + public static <T>Constructor<T> getConstructor(final Class<T> clazz, final Class<?>... argTypes) + throws SecurityException, NoSuchMethodException { + return clazz.getConstructor(argTypes); + } + + /** + * {@link Class}オブジェクトが表すクラスまたはインタフェースの指定されたコンストラクタを + * リフレクトする{@link Constructor}オブジェクトを取得する。 + * + * @param <T> {@link Class}オブジェクトが表すクラス + * @param clazz クラスの{@link Class}オブジェクト + * @param argTypes パラメータ配列 + * @return 指定された{@code argTypes}と一致するコンストラクタの{@link Constructor}オブジェクト + * @throws NoSuchMethodException メソッドが見つからなかった場合 + * @throws SecurityException セキュリティ違反が発生した場合 + * @see Class#getDeclaredConstructor(Class[]) + */ + public static <T>Constructor<T> getDeclaredConstructor(final Class<T> clazz, final Class<?>... argTypes) + throws SecurityException, NoSuchMethodException { + return clazz.getDeclaredConstructor(argTypes); + } + + /** + * {@link Class}オブジェクトが表すクラスまたはインタフェースの指定された宣言フィールドをリフレクトする + * {@link Field}オブジェクトを取得する。 + * + * @param clazz クラスの{@link Class}オブジェクト + * @param name フィールド名 + * @return {@code name}で指定されたこのクラスの{@link Field}オブジェクト + * @throws NoSuchFieldException メソッドが見つからなかった場合 + * @throws SecurityException セキュリティ違反が発生した場合 + * @see Class#getDeclaredField(String) + */ + public static Field getDeclaredField(final Class<?> clazz, final String name) throws SecurityException, + NoSuchFieldException { + return clazz.getDeclaredField(name); + } + + /** + * {@link Class}オブジェクトが表すクラスまたはインタフェースの指定された宣言フィールドをリフレクトする + * {@link Field}オブジェクトを取得する。ただし例外をスローしない。 + * + * @param clazz クラスの{@link Class}オブジェクト + * @param name フィールド名 + * @return {@code name}で指定されたこのクラスの{@link Field}オブジェクト. 例外が発生した場合は{@code null} + * @see Class#getDeclaredField(String) + */ + public static Field getDeclaredFieldNoException(final Class<?> clazz, final String name) { + try { + return clazz.getDeclaredField(name); + } catch (SecurityException e) { + return null; + } catch (NoSuchFieldException e) { + return null; + } + } + + /** + * {@link Class}オブジェクトが表すクラスまたはインタフェースの指定されたメンバメソッドを + * リフレクトする{@link Method}オブジェクトを取得する。 + * + * @param clazz クラスの{@link Class}オブジェクト + * @param name メソッドの名前 + * @param argTypes パラメータのリスト + * @return 指定された{@code name}および{@code argTypes}と一致する{@link Method}オブジェクト + * @throws NoSuchMethodException メソッドが見つからない場合 + * @throws SecurityException セキュリティ違反が発生した場合 + * @see Class#getDeclaredMethod(String, Class[]) + */ + public static Method getDeclaredMethod(final Class<?> clazz, final String name, final Class<?>... argTypes) + throws SecurityException, NoSuchMethodException { + return clazz.getDeclaredMethod(name, argTypes); + } + + /** + * パラメタ化されたコレクションの要素型を取得する。 + * + * @param parameterizedCollection パラメタ化されたコレクションの型 + * @return パラメタ化されたコレクションの要素型 + */ + public static Class<?> getElementTypeOfCollection(final Type parameterizedCollection) { + return GenericUtil.getRawClass(GenericUtil.getElementTypeOfCollection(parameterizedCollection)); + } + + /** + * 指定されたフィールドのパラメタ化されたコレクションの要素型を取得する。 + * + * @param field フィールド + * @return 指定されたフィールドのパラメタ化されたコレクションの要素型 since 2.4.18 + * since 2.4.18 + */ + public static Class<?> getElementTypeOfCollectionFromFieldType(final Field field) { + final Type type = field.getGenericType(); + return getElementTypeOfCollection(type); + } + + /** + * 指定されたメソッドの引数型として宣言されているパラメタ化されたコレクションの要素型を取得する。 + * + * @param method メソッド + * @param parameterPosition パラメタ化されたコレクションが宣言されているメソッド引数の位置 + * @return 指定されたメソッドの引数型として宣言されているパラメタ化されたコレクションの要素型 + */ + public static Class<?> getElementTypeOfCollectionFromParameterType(final Method method, final int parameterPosition) { + final Type[] parameterTypes = method.getGenericParameterTypes(); + return getElementTypeOfCollection(parameterTypes[parameterPosition]); + } + + /** + * 指定されたメソッドの戻り値型として宣言されているパラメタ化されたコレクションの要素型を取得する。 + * + * @param method メソッド + * @return 指定されたメソッドの戻り値型として宣言されているパラメタ化されたコレクションの要素型 + */ + public static Class<?> getElementTypeOfCollectionFromReturnType(final Method method) { + return getElementTypeOfCollection(method.getGenericReturnType()); + } + + /** + * パラメタ化されたリストの要素型を取得する。 + * + * @param parameterizedList パラメタ化されたリストの型 + * @return パラメタ化されたリストの要素型 + */ + public static Class<?> getElementTypeOfList(final Type parameterizedList) { + return GenericUtil.getRawClass(GenericUtil.getElementTypeOfList(parameterizedList)); + } + + /** + * 指定されたフィールドのパラメタ化されたリストの要素型を取得する。 + * + * @param field フィールド + * @return 指定されたフィールドのパラメタ化されたリストの要素型 + */ + public static Class<?> getElementTypeOfListFromFieldType(final Field field) { + final Type type = field.getGenericType(); + return getElementTypeOfList(type); + } + + /** + * 指定されたメソッドの引数型として宣言されているパラメタ化されたリストの要素型を取得する。 + * + * @param method メソッド + * @param parameterPosition パラメタ化されたリストが宣言されているメソッド引数の位置 + * @return 指定されたメソッドの引数型として宣言されているパラメタ化されたリストの要素型 + */ + public static Class<?> getElementTypeOfListFromParameterType(final Method method, final int parameterPosition) { + final Type[] parameterTypes = method.getGenericParameterTypes(); + return getElementTypeOfList(parameterTypes[parameterPosition]); + } + + /** + * 指定されたメソッドの戻り値型として宣言されているパラメタ化されたリストの要素型を取得する。 + * + * @param method メソッド + * @return 指定されたメソッドの戻り値型として宣言されているパラメタ化されたリストの要素型 + */ + public static Class<?> getElementTypeOfListFromReturnType(final Method method) { + return getElementTypeOfList(method.getGenericReturnType()); + } + + /** + * パラメタ化されたセットの要素型を取得する。 + * + * @param parameterizedSet パラメタ化されたセットの型 + * @return パラメタ化されたセットの要素型 + */ + public static Class<?> getElementTypeOfSet(final Type parameterizedSet) { + return GenericUtil.getRawClass(GenericUtil.getElementTypeOfSet(parameterizedSet)); + } + + /** + * 指定されたフィールドのパラメタ化されたセットの要素型を取得する。 + * + * @param field フィールド + * @return 指定されたフィールドのパラメタ化されたセットの要素型 since 2.4.18 + */ + public static Class<?> getElementTypeOfSetFromFieldType(final Field field) { + final Type type = field.getGenericType(); + return getElementTypeOfSet(type); + } + + /** + * 指定されたメソッドの引数型として宣言されているパラメタ化されたセットの要素型を取得する。 + * + * @param method メソッド + * @param parameterPosition パラメタ化されたセットが宣言されているメソッド引数の位置 + * @return 指定されたメソッドの引数型として宣言されているパラメタ化されたセットの要素型 + */ + public static Class<?> getElementTypeOfSetFromParameterType(final Method method, final int parameterPosition) { + final Type[] parameterTypes = method.getGenericParameterTypes(); + return getElementTypeOfSet(parameterTypes[parameterPosition]); + } + + /** + * 指定されたメソッドの戻り値型として宣言されているパラメタ化されたセットの要素型を取得する。 + * + * @param method メソッド + * @return 指定されたメソッドの戻り値型として宣言されているパラメタ化されたセットの要素型 + */ + public static Class<?> getElementTypeOfSetFromReturnType(final Method method) { + return getElementTypeOfSet(method.getGenericReturnType()); + } + + /** + * {@link Class}オブジェクトが表すクラスまたはインタフェースの指定された{@code public}メンバフィールドをリフレクトする{@link Field}オブジェクトを取得する。 + * + * @param clazz クラスの{@link Class}オブジェクト + * @param name フィールド名 + * @return {@code name}で指定されたこのクラスの{@link Field}オブジェクト + * @throws NoSuchFieldException フィールドが見つからなかった場合 + * @throws SecurityException セキュリティ違反が発生した場合 + * @see Class#getField(String) + */ + public static Field getField(final Class<?> clazz, final String name) throws SecurityException, + NoSuchFieldException { + return clazz.getField(name); + } + + /** + * {@link Class}オブジェクトが表すクラスまたはインタフェースの指定された{@code public}メンバメソッドを + * リフレクトする{@link Method}オブジェクトを取得する。 + * + * @param clazz クラスの{@link Class}オブジェクト + * @param name メソッドの名前 + * @param argTypes パラメータのリスト + * @return 指定された{@code name}および{@code argTypes}と一致する{@link Method}オブジェクト + * @throws NoSuchMethodException メソッドが見つからなかった場合 + * @throws SecurityException セキュリティ違反が発生した場合 + * @see Class#getMethod(String, Class[]) + */ + public static Method getMethod(final Class<?> clazz, final String name, final Class<?>... argTypes) + throws SecurityException, NoSuchMethodException { + return clazz.getMethod(name, argTypes); + } + + /** + * 指定されたオブジェクトについて、{@link Field}によって表される{@code static}フィールドの値を取得する。 + * + * @param <T> フィールドの型 + * @param field フィールド + * @return {@code static}フィールドで表現される値 + * @throws IllegalAccessException 基本となるフィールドにアクセスできない場合 + * @see Field#get(Object) + */ + @SuppressWarnings("unchecked") + public static <T>T getStaticValue(final Field field) throws IllegalAccessException { + return (T) getValue(field, null); + } + + /** + * 指定されたオブジェクトについて、{@link Field}によって表されるフィールドの値を取得する。 + * + * @param <T> フィールドの型 + * @param field フィールド + * @param target 表現されるフィールド値の抽出元オブジェクト + * @return オブジェクト{@code obj}内で表現される値 + * @throws IllegalAccessException 基本となるフィールドにアクセスできない場合 + * @see Field#get(Object) + */ + @SuppressWarnings("unchecked") + public static <T>T getValue(final Field field, final Object target) throws IllegalAccessException { + return (T) field.get(target); + } + + /** + * {@link Method}オブジェクトによって表される基本となるメソッドを、指定したオブジェクトに対して指定したパラメータで呼び出す。 + * + * @param <T> メソッドの戻り値の型 + * @param method メソッド + * @param target 基本となるメソッドの呼び出し元のオブジェクト + * @param args メソッド呼び出しに使用される引数 + * @return このオブジェクトが表すメソッドを、パラメータ{@code args}を使用して{@code obj}にディスパッチした結果 + * @throws InvocationTargetException 基本となるメソッドが例外をスローする場合 + * @throws IllegalAccessException この{@link Method}オブジェクトがJava言語アクセス制御を実施し基本となるメソッドにアクセスできない場合 + * @throws IllegalArgumentException 不正な引数、または不適切な引数をメソッドに渡した場合 + * @see Method#invoke(Object, Object[]) + */ + @SuppressWarnings("unchecked") + public static <T>T invoke(final Method method, final Object target, final Object... args) + throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { + return (T) method.invoke(target, args); + } + + /** + * {@link Method}オブジェクトによって表される基本となる{@code static}メソッドを指定したパラメータで呼び出す。 + * + * @param <T> メソッドの戻り値の型 + * @param method メソッド + * @param args メソッド呼び出しに使用される引数 + * @return このオブジェクトが表す{@code static}メソッドを、パラメータ{@code args}を使用してディスパッチした結果 + * @throws InvocationTargetException 基本となるメソッドが例外をスローする場合 + * @throws IllegalAccessException この{@link Method}オブジェクトがJava言語アクセス制御を実施し基本となるメソッドにアクセスできない場合 + * @throws IllegalArgumentException 不正な引数、または不適切な引数をメソッドに渡した場合 + * @see Method#invoke(Object, Object[]) + */ + @SuppressWarnings("unchecked") + public static <T>T invokeStatic(final Method method, final Object... args) throws IllegalArgumentException, + IllegalAccessException, InvocationTargetException { + return (T) invoke(method, null, args); + } + + /** + * メソッドがアクセサメソッドかどうかを調べる。 + * + * @param method メソッド + * @return アクセサであれば{@code true} + */ + public static boolean isAccessor(Method method) { + return isGetter(method) || isSetter(method); + } + + /** + * メソッドがgetterかどうか調べる。 + * + * @param method メソッド + * @return getterであれば{@code true} + */ + public static boolean isGetter(Method method) { + Class<?>[] parameterTypes = method.getParameterTypes(); + if (parameterTypes.length != 0) { + return false; + } + Class<?> returnType = method.getReturnType(); + String name = method.getName(); + if (returnType == void.class || returnType == Void.class) { + return false; + } else if (returnType == boolean.class || returnType == Boolean.class) { + boolean result = + name.startsWith(IS) && name.length() > 2 && CharUtils.isAsciiAlphaUpper(name.toCharArray()[2]); + if (result == true) { + return true; + } + } + return name.startsWith(GET) && name.length() > 3 && CharUtils.isAsciiAlphaUpper(name.toCharArray()[3]); + } + + /** + * メソッドがsetterかどうか調べる。 + * + * @param method メソッド + * @return setterであれば{@code true} + */ + public static boolean isSetter(Method method) { + Class<?>[] parameterTypes = method.getParameterTypes(); + if (parameterTypes.length != 1) { + return false; + } + Class<?> returnType = method.getReturnType(); + if (returnType != void.class && returnType != Void.class) { + return false; + } + String name = method.getName(); + return name.startsWith(SET) && name.length() > 3 && CharUtils.isAsciiAlphaUpper(name.toCharArray()[3]); + } + + /** + * 指定されたクラスのデフォルトコンストラクタで、クラスの新しいインスタンスを作成および初期化する。 + * + * @param <T> {@link Class}オブジェクトが表すクラス + * @param clazz クラスを表す{@link Class}オブジェクト + * @return このオブジェクトが表すコンストラクタを呼び出すことで作成される新規オブジェクト + * @throws InstantiationException 基本となるコンストラクタを宣言するクラスが{@code abstract}クラスを表す場合 + * @throws IllegalAccessException 実パラメータ数と仮パラメータ数が異なる場合、 + * プリミティブ引数のラップ解除変換が失敗した場合、 またはラップ解除後、 + * メソッド呼び出し変換によってパラメータ値を対応する仮パラメータ型に変換できない場合、 + * このコンストラクタが列挙型に関連している場合 + * @see Constructor#newInstance(Object[]) + */ + public static <T>T newInstance(final Class<T> clazz) throws InstantiationException, IllegalAccessException { + return clazz.newInstance(); + } + + /** + * 指定された初期化パラメータで、コンストラクタの宣言クラスの新しいインスタンスを作成および初期化する。 + * + * @param <T> コンストラクタの宣言クラス + * @param constructor コンストラクタ + * @param args コンストラクタ呼び出しに引数として渡すオブジェクトの配列 + * @return コンストラクタを呼び出すことで作成される新規オブジェクト + * @throws InstantiationException 基本となるコンストラクタを宣言するクラスが{@code abstract}クラスを表す場合 + * @throws IllegalAccessException 実パラメータ数と仮パラメータ数が異なる場合、 + * プリミティブ引数のラップ解除変換が失敗した場合、 またはラップ解除後、 + * メソッド呼び出し変換によってパラメータ値を対応する仮パラメータ型に変換できない場合、 + * このコンストラクタが列挙型に関連している場合 + * @throws InvocationTargetException 基本となるメソッドが例外をスローする場合 + * @throws IllegalArgumentException 不正な引数、または不適切な引数をメソッドに渡した場合 + * @see Constructor#newInstance(Object[]) + */ + public static <T>T newInstance(final Constructor<T> constructor, final Object... args) + throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + return constructor.newInstance(args); + } + + /** + * {@link Field}オブジェクトによって表される{@code static}フィールドを、指定された新しい値に設定する。 + * + * @param field フィールド + * @param value {@code static}フィールドの新しい値 + * @throws IllegalAccessException 基本となるフィールドにアクセスできない場合 + * @see Field#set(Object, Object) + */ + public static void setStaticValue(final Field field, final Object value) throws IllegalAccessException { + setValue(field, null, value); + } + + /** + * {@link Field}オブジェクトによって表される指定されたオブジェクト引数のフィールドを、指定された新しい値に設定する。 + * + * @param field フィールド + * @param target フィールドを変更するオブジェクト + * @param value 変更中の{@code target}の新しいフィールド値 + * @throws IllegalAccessException 基本となるフィールドにアクセスできない場合 + * @see Field#set(Object, Object) + */ + public static void setValue(final Field field, final Object target, final Object value) + throws IllegalAccessException { + field.set(target, value); + } + + private ReflectionUtil() { + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ReflectionUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceBundleUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceBundleUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceBundleUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,110 +1,110 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link ResourceBundle}用のユーティリティクラス。 - * - * @author j5ik2o - * - */ -public class ResourceBundleUtil { - - /** - * {@link Map}に変換します。 - * - * @param bundle バンドル - * @return {@link Map} - */ - public static final Map<String, String> convertMap(ResourceBundle bundle) { - Map<String, String> ret = new HashMap<String, String>(); - for (Enumeration<String> e = bundle.getKeys(); e.hasMoreElements();) { - String key = e.nextElement(); - String value = bundle.getString(key); - ret.put(key, value); - } - return ret; - } - - /** - * {@link Map}に変換します。 - * - * @param name 名前 - * @param locale ロケール - * @return {@link Map} - */ - public static final Map<String, String> convertMap(String name, Locale locale) { - ResourceBundle bundle = getBundle(name, locale); - return convertMap(bundle); - } - - /** - * バンドルを返します。 見つからない場合は、<code>null</code>を返します。 - * - * @param name 名前 - * @param locale ロケール - * @return {@link ResourceBundle} - * @see ResourceBundle#getBundle(String, Locale) - */ - public static final ResourceBundle getBundle(String name, Locale locale) { - if (locale == null) { - locale = Locale.getDefault(); - } - try { - return ResourceBundle.getBundle(name, locale); - } catch (MissingResourceException ignore) { - return null; - } - } - - /** - * バンドルを返します。 見つからない場合は、<code>null</code>を返します。 - * - * @param name 名前 - * @param locale ロケール - * @param classLoader クラスローダ - * @return {@link ResourceBundle} - * @see ResourceBundle#getBundle(String, Locale, ClassLoader) - */ - public static final ResourceBundle getBundle(String name, Locale locale, ClassLoader classLoader) { - if (locale == null) { - locale = Locale.getDefault(); - } - try { - return ResourceBundle.getBundle(name, locale, classLoader); - } catch (MissingResourceException ignore) { - return null; - } - } - - /** - * インスタンスを構築します。 - */ - private ResourceBundleUtil() { - throw new JiemamyError("不到達ポイント"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link ResourceBundle}用のユーティリティクラス。 + * + * @author j5ik2o + * + */ +public class ResourceBundleUtil { + + /** + * {@link Map}に変換します。 + * + * @param bundle バンドル + * @return {@link Map} + */ + public static final Map<String, String> convertMap(ResourceBundle bundle) { + Map<String, String> ret = new HashMap<String, String>(); + for (Enumeration<String> e = bundle.getKeys(); e.hasMoreElements();) { + String key = e.nextElement(); + String value = bundle.getString(key); + ret.put(key, value); + } + return ret; + } + + /** + * {@link Map}に変換します。 + * + * @param name 名前 + * @param locale ロケール + * @return {@link Map} + */ + public static final Map<String, String> convertMap(String name, Locale locale) { + ResourceBundle bundle = getBundle(name, locale); + return convertMap(bundle); + } + + /** + * バンドルを返します。 見つからない場合は、<code>null</code>を返します。 + * + * @param name 名前 + * @param locale ロケール + * @return {@link ResourceBundle} + * @see ResourceBundle#getBundle(String, Locale) + */ + public static final ResourceBundle getBundle(String name, Locale locale) { + if (locale == null) { + locale = Locale.getDefault(); + } + try { + return ResourceBundle.getBundle(name, locale); + } catch (MissingResourceException ignore) { + return null; + } + } + + /** + * バンドルを返します。 見つからない場合は、<code>null</code>を返します。 + * + * @param name 名前 + * @param locale ロケール + * @param classLoader クラスローダ + * @return {@link ResourceBundle} + * @see ResourceBundle#getBundle(String, Locale, ClassLoader) + */ + public static final ResourceBundle getBundle(String name, Locale locale, ClassLoader classLoader) { + if (locale == null) { + locale = Locale.getDefault(); + } + try { + return ResourceBundle.getBundle(name, locale, classLoader); + } catch (MissingResourceException ignore) { + return null; + } + } + + /** + * インスタンスを構築します。 + */ + private ResourceBundleUtil() { + throw new JiemamyError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceBundleUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceNotFoundException.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceNotFoundException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceNotFoundException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,49 +1,49 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -/** - * リソースが見つからなかったときにスローされる例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class ResourceNotFoundException extends Exception { - - private String path; - - - /** - * {@link ResourceNotFoundException}を作成する。 - * - * @param path パス - */ - public ResourceNotFoundException(String path) { - super(path); - this.path = path; - } - - /** - * パスを返します。 - * - * @return パス - */ - public String getPath() { - return path; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +/** + * リソースが見つからなかったときにスローされる例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class ResourceNotFoundException extends Exception { + + private String path; + + + /** + * {@link ResourceNotFoundException}を作成する。 + * + * @param path パス + */ + public ResourceNotFoundException(String path) { + super(path); + this.path = path; + } + + /** + * パスを返します。 + * + * @return パス + */ + public String getPath() { + return path; + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceNotFoundException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceTraversal.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceTraversal.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceTraversal.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,146 +1,146 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.Enumeration; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - -import org.jiemamy.exception.JiemamyError; - -/** - * リソースを横断的に処理するためのクラス。 - * - * @author j5ik2o - */ -public class ResourceTraversal { - - /** - * リソースを横断的に処理する。 - * - * @param rootDir ルートディレクトリ - * @param handler ハンドラ - * @throws IOException 入出力が失敗した場合 - * @throws TraversalHandlerException ハンドラの処理が失敗した場合 - */ - public static void forEach(final File rootDir, final ResourceHandler handler) throws IOException, - TraversalHandlerException { - forEach(rootDir, null, handler); - } - - /** - * リソースを横断的に処理する。 - * - * @param rootDir ルートディレクトリ - * @param baseDirectory ベースディレクトリ - * @param handler ハンドラ - * @throws IOException 入出力が失敗した場合 - * @throws TraversalHandlerException ハンドラの処理が失敗した場合 - */ - public static void forEach(final File rootDir, final String baseDirectory, final ResourceHandler handler) - throws IOException, TraversalHandlerException { - final File baseDir = getBaseDir(rootDir, baseDirectory); - if (baseDir.exists()) { - traverseFileSystem(rootDir, baseDir, handler); - } - } - - /** - * リソースを横断的に処理する。 - * - * @param jarFile JarFile - * @param handler ハンドラ - * @throws IOException 入出力が失敗した場合 - * @throws TraversalHandlerException ハンドラの処理が失敗した場合 - */ - public static void forEach(final JarFile jarFile, final ResourceHandler handler) throws IOException, - TraversalHandlerException { - final Enumeration<JarEntry> enumeration = jarFile.entries(); - while (enumeration.hasMoreElements()) { - final JarEntry entry = enumeration.nextElement(); - if (!entry.isDirectory()) { - final String entryName = entry.getName().replace('\\', '/'); - final InputStream is = JarFileUtil.getInputStream(jarFile, entry); - try { - handler.processResource(entryName, is); - } finally { - InputStreamUtil.close(is); - } - } - } - } - - private static File getBaseDir(final File rootDir, final String baseDirectory) { - File baseDir = rootDir; - if (baseDirectory != null) { - final String[] names = baseDirectory.split("/"); - for (String name : names) { - baseDir = new File(baseDir, name); - } - } - return baseDir; - } - - private static void traverseFileSystem(final File rootDir, final File baseDir, final ResourceHandler handler) - throws IOException, TraversalHandlerException { - final File[] files = baseDir.listFiles(); - for (int i = 0; i < files.length; ++i) { - final File file = files[i]; - if (file.isDirectory()) { - traverseFileSystem(rootDir, file, handler); - } else { - final int pos = FileUtil.getCanonicalPath(rootDir).length(); - final String filePath = FileUtil.getCanonicalPath(file); - final String resourcePath = filePath.substring(pos + 1).replace('\\', '/'); - final InputStream is = FileInputStreamUtil.create(file); - try { - handler.processResource(resourcePath, is); - } finally { - InputStreamUtil.close(is); - } - } - } - } - - /** - * インスタンスを構築します。 - */ - private ResourceTraversal() { - throw new JiemamyError("不到達ポイント"); - } - - - /** - * リソースを処理するインターフェースです。 - * - */ - public interface ResourceHandler { - - /** - * リソースを処理します。 - * - * @param path パス - * @param is {@link InputStream} - * @throws TraversalHandlerException ハンドラの処理に失敗した場合 - */ - void processResource(String path, InputStream is) throws TraversalHandlerException; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Enumeration; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +import org.jiemamy.exception.JiemamyError; + +/** + * リソースを横断的に処理するためのクラス。 + * + * @author j5ik2o + */ +public class ResourceTraversal { + + /** + * リソースを横断的に処理する。 + * + * @param rootDir ルートディレクトリ + * @param handler ハンドラ + * @throws IOException 入出力が失敗した場合 + * @throws TraversalHandlerException ハンドラの処理が失敗した場合 + */ + public static void forEach(final File rootDir, final ResourceHandler handler) throws IOException, + TraversalHandlerException { + forEach(rootDir, null, handler); + } + + /** + * リソースを横断的に処理する。 + * + * @param rootDir ルートディレクトリ + * @param baseDirectory ベースディレクトリ + * @param handler ハンドラ + * @throws IOException 入出力が失敗した場合 + * @throws TraversalHandlerException ハンドラの処理が失敗した場合 + */ + public static void forEach(final File rootDir, final String baseDirectory, final ResourceHandler handler) + throws IOException, TraversalHandlerException { + final File baseDir = getBaseDir(rootDir, baseDirectory); + if (baseDir.exists()) { + traverseFileSystem(rootDir, baseDir, handler); + } + } + + /** + * リソースを横断的に処理する。 + * + * @param jarFile JarFile + * @param handler ハンドラ + * @throws IOException 入出力が失敗した場合 + * @throws TraversalHandlerException ハンドラの処理が失敗した場合 + */ + public static void forEach(final JarFile jarFile, final ResourceHandler handler) throws IOException, + TraversalHandlerException { + final Enumeration<JarEntry> enumeration = jarFile.entries(); + while (enumeration.hasMoreElements()) { + final JarEntry entry = enumeration.nextElement(); + if (!entry.isDirectory()) { + final String entryName = entry.getName().replace('\\', '/'); + final InputStream is = JarFileUtil.getInputStream(jarFile, entry); + try { + handler.processResource(entryName, is); + } finally { + InputStreamUtil.close(is); + } + } + } + } + + private static File getBaseDir(final File rootDir, final String baseDirectory) { + File baseDir = rootDir; + if (baseDirectory != null) { + final String[] names = baseDirectory.split("/"); + for (String name : names) { + baseDir = new File(baseDir, name); + } + } + return baseDir; + } + + private static void traverseFileSystem(final File rootDir, final File baseDir, final ResourceHandler handler) + throws IOException, TraversalHandlerException { + final File[] files = baseDir.listFiles(); + for (int i = 0; i < files.length; ++i) { + final File file = files[i]; + if (file.isDirectory()) { + traverseFileSystem(rootDir, file, handler); + } else { + final int pos = FileUtil.getCanonicalPath(rootDir).length(); + final String filePath = FileUtil.getCanonicalPath(file); + final String resourcePath = filePath.substring(pos + 1).replace('\\', '/'); + final InputStream is = FileInputStreamUtil.create(file); + try { + handler.processResource(resourcePath, is); + } finally { + InputStreamUtil.close(is); + } + } + } + } + + /** + * インスタンスを構築します。 + */ + private ResourceTraversal() { + throw new JiemamyError("不到達ポイント"); + } + + + /** + * リソースを処理するインターフェースです。 + * + */ + public interface ResourceHandler { + + /** + * リソースを処理します。 + * + * @param path パス + * @param is {@link InputStream} + * @throws TraversalHandlerException ハンドラの処理に失敗した場合 + */ + void processResource(String path, InputStream is) throws TraversalHandlerException; + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceTraversal.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,453 +1,453 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.util.Properties; - -import org.jiemamy.exception.JiemamyError; - -/** - * リソース用のユーティリティクラス。 - * - * @author j5ik2o - * - */ -public class ResourceUtil { - - /** - * パスを変換する。 - * - * @param path パス - * @param clazz クラス - * @return 変換された結果 - */ - public static String convertPath(String path, Class<?> clazz) { - if (isExist(path)) { - return path; - } - String prefix = clazz.getName().replace('.', '/').replaceFirst("/[^/]+$", ""); - String extendedPath = prefix + "/" + path; - if (ResourceUtil.getResourceNoException(extendedPath) != null) { - return extendedPath; - } - return path; - } - - /** - * クラスファイルが置かれているルートディレクトリを取得する。 - * - * @param clazz クラス - * @return ルートディレクトリ - * @throws ResourceNotFoundException リソースが見つからなかった場合 - * @throws IOException 入出力が失敗した場合 - * @see #getBuildDir(String) - */ - public static File getBuildDir(Class<?> clazz) throws ResourceNotFoundException, IOException { - return getBuildDir(getResourcePath(clazz)); - } - - /** - * クラスファイルが置かれているルートディレクトリを取得する。 - * - * @param path パス - * @return ルートディレクトリ - * @throws ResourceNotFoundException リソースが見つからなかった場合 - * @throws IOException 入出力が失敗した場合 - */ - public static File getBuildDir(String path) throws ResourceNotFoundException, IOException { - File dir = null; - URL url = getResource(path); - if ("file".equals(url.getProtocol())) { - int num = path.split("/").length; - dir = new File(getFileName(url)); - for (int i = 0; i < num; ++i, dir = dir.getParentFile()) { - // nop - } - } else { - dir = new File(JarFileUtil.toJarFilePath(url)); - } - return dir; - } - - /** - * クラスファイルが置かれているルートディレクトリを取得する。 - * - * @param clazz クラス - * @return ルートディレクトリ - * @see #getBuildDir(String) - */ - public static File getBuildDirNoException(Class<?> clazz) { - try { - File buildDir = ResourceUtil.getBuildDir(clazz); - return buildDir; - } catch (ResourceNotFoundException ignore) { - return null; - } catch (IOException ignore) { - return null; - } - } - - /** - * クラスローダを取得する。 - * - * @return クラスローダ - */ - public static ClassLoader getClassLoader() { - return Thread.currentThread().getContextClassLoader(); - } - - /** - * 拡張子を取得する。 - * - * @param path パス - * @return 拡張子 - */ - public static String getExtension(String path) { - int extPos = path.lastIndexOf("."); - if (extPos >= 0) { - return path.substring(extPos + 1); - } - return null; - } - - /** - * ファイルを取得する。 - * - * @param url URL - * @return ファイル - * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされていない場合 - */ - public static File getFile(URL url) throws UnsupportedEncodingException { - File file = new File(getFileName(url)); - if (file.exists()) { - return file; - } - return null; - } - - /** - * ファイル名を取得する。 - * - * @param url URL - * @return ファイル名 - * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされていない場合 - */ - public static String getFileName(URL url) throws UnsupportedEncodingException { - String s = url.getFile(); - return URLUtil.decode(s, "UTF8"); - } - - /** - * プロパティファイルを取得する。 - * - * @param path パス - * @return プロパティファイル - * @throws IOException 入出力が失敗した場合 - * @throws ResourceNotFoundException リソースが見つからなかった場合 - */ - public static Properties getProperties(String path) throws ResourceNotFoundException, IOException { - Properties props = new Properties(); - InputStream is = getResourceAsStream(path); - - props.load(is); - return props; - - } - - /** - * リソースを取得する。 - * - * @param path パス - * @return リソース - * @throws ResourceNotFoundException リソースが見つからなかった場合 - * @see #getResource(String, String) - */ - public static URL getResource(String path) throws ResourceNotFoundException { - return getResource(path, null); - } - - /** - * リソースを取得する。 - * - * @param path パス - * @param extension 拡張子 - * @return リソース - * @throws ResourceNotFoundException リソースが見つからなかった場合 - */ - public static URL getResource(String path, String extension) throws ResourceNotFoundException { - URL url = getResourceNoException(path, extension); - if (url != null) { - return url; - } - throw new ResourceNotFoundException(getResourcePath(path, extension)); - } - - /** - * リソースをファイルで取得する。 - * - * @param path パス - * @return ファイル - * @throws ResourceNotFoundException リソースが見つからなかった場合 - * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされていない場合 - * @see #getResourceAsFile(String, String) - */ - public static File getResourceAsFile(String path) throws ResourceNotFoundException, UnsupportedEncodingException { - return getResourceAsFile(path, null); - } - - /** - * リソースをファイルで取得する。 - * - * @param path パス - * @param extension 拡張子 - * @return ファイル - * @throws ResourceNotFoundException リソースが見つからなかった場合 - * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされていない場合 - * @see #getFile(URL) - */ - public static File getResourceAsFile(String path, String extension) throws ResourceNotFoundException, - UnsupportedEncodingException { - return getFile(getResource(path, extension)); - } - - /** - * リソースをファイルで取得する。 - * <p> - * リソースが見つからない場合は<code>null</code>。 - * </p> - * - * @param clazz クラス - * @return ファイル - * @see #getResourceAsFileNoException(String) - */ - public static File getResourceAsFileNoException(Class<?> clazz) { - return getResourceAsFileNoException(getResourcePath(clazz)); - } - - /** - * リソースをファイルで取得する。 - * <p> - * リソースが見つからない場合は<code>null</code>。 - * </p> - * - * @param path パス - * @return ファイル - * @see #getResourceNoException(String) - */ - public static File getResourceAsFileNoException(String path) { - URL url = getResourceNoException(path); - if (url == null) { - return null; - } - try { - return getFile(url); - } catch (UnsupportedEncodingException e) { - return null; - } - } - - /** - * リソースをストリームで取得する。 - * - * @param path パス - * @return ストリーム - * @throws ResourceNotFoundException リソースが見つからなかった場合 - * @throws IOException 入出力が失敗した場合 - * @see #getResourceAsStream(String, String) - */ - public static InputStream getResourceAsStream(String path) throws ResourceNotFoundException, IOException { - return getResourceAsStream(path, null); - } - - /** - * リソースをストリームで取得する。 - * - * @param path パス - * @param extension 拡張子 - * @return ストリーム - * @throws ResourceNotFoundException リソースが見つからなかった場合 - * @throws IOException 入出力が失敗した場合 - * @see #getResource(String, String) - */ - public static InputStream getResourceAsStream(String path, String extension) throws ResourceNotFoundException, - IOException { - URL url = getResource(path, extension); - return URLUtil.openStream(url); - } - - /** - * リソースをストリームで取得する。 - * <p> - * リソースが見つからなかった場合は<code>null</code>。 - * </p> - * - * @param path パス - * @return ストリーム - * @see #getResourceAsStreamNoException(String, String) - */ - public static InputStream getResourceAsStreamNoException(String path) { - return getResourceAsStreamNoException(path, null); - } - - /** - * リソースをストリームとして取得する。 - * <p> - * リソースが見つからなかった場合は<code>null</code>。 - * </p> - * - * @param path パス - * @param extension 拡張子 - * @return ストリーム - * @see #getResourceNoException(String, String) - */ - public static InputStream getResourceAsStreamNoException(String path, String extension) { - URL url = getResourceNoException(path, extension); - if (url == null) { - return null; - } - try { - return url.openStream(); - } catch (final IOException e) { - return null; - } - } - - /** - * リソースを取得する。 - * <p> - * 見つからなかった場合は<code>null</code>を返します。 - * </p> - * - * @param path パス - * @return リソース - * @see #getResourceNoException(String, String) - */ - public static URL getResourceNoException(String path) { - return getResourceNoException(path, null); - } - - /** - * リソースを取得する。 - * <p> - * 見つからなかった場合は<code>null</code>。 - * </p> - * - * @param path パス - * @param extension 拡張子 - * @return リソース - * @see #getResourceNoException(String, String, ClassLoader) - */ - public static URL getResourceNoException(String path, String extension) { - return getResourceNoException(path, extension, Thread.currentThread().getContextClassLoader()); - } - - /** - * リソースを取得する。 - * <p> - * 見つからなかった場合は<code>null</code>。 - * </p> - * - * @param path パス - * @param extension 拡張子 - * @param loader クラスローダ - * @return リソース - * @see #getResourcePath(String, String) - */ - public static URL getResourceNoException(String path, String extension, ClassLoader loader) { - if (path == null || loader == null) { - return null; - } - path = getResourcePath(path, extension); - return loader.getResource(path); - } - - /** - * リソースパスを取得する。 - * - * @param clazz クラス - * @return リソースパス - */ - public static String getResourcePath(Class<?> clazz) { - return clazz.getName().replace('.', '/') + ".class"; - } - - /** - * リソースパスを取得する。 - * - * @param path パス - * @param extension 拡張子 - * @return リソースパス - */ - public static String getResourcePath(String path, String extension) { - if (extension == null) { - return path; - } - extension = "." + extension; - if (path.endsWith(extension)) { - return path; - } - return path.replace('.', '/') + extension; - } - - /** - * リソースの存在有無を取得する。 - * - * @param path パス - * @return リソースが存在するかどうか - * @see #getResourceNoException(String) - */ - public static boolean isExist(String path) { - return getResourceNoException(path) != null; - } - - /** - * 拡張子を除去する。 - * - * @param path パス - * @return 取り除いた後の結果 - */ - public static String removeExtension(String path) { - int extPos = path.lastIndexOf("."); - if (extPos >= 0) { - return path.substring(0, extPos); - } - return path; - } - - /** - * 外部形式に変換する。 - * - * @param url URL - * @return 外部形式 - * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされていない場合 - */ - public static String toExternalForm(URL url) throws UnsupportedEncodingException { - String s = url.toExternalForm(); - return URLUtil.decode(s, "UTF8"); - } - - private ResourceUtil() { - throw new JiemamyError("不到達ポイント"); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.util.Properties; + +import org.jiemamy.exception.JiemamyError; + +/** + * リソース用のユーティリティクラス。 + * + * @author j5ik2o + * + */ +public class ResourceUtil { + + /** + * パスを変換する。 + * + * @param path パス + * @param clazz クラス + * @return 変換された結果 + */ + public static String convertPath(String path, Class<?> clazz) { + if (isExist(path)) { + return path; + } + String prefix = clazz.getName().replace('.', '/').replaceFirst("/[^/]+$", ""); + String extendedPath = prefix + "/" + path; + if (ResourceUtil.getResourceNoException(extendedPath) != null) { + return extendedPath; + } + return path; + } + + /** + * クラスファイルが置かれているルートディレクトリを取得する。 + * + * @param clazz クラス + * @return ルートディレクトリ + * @throws ResourceNotFoundException リソースが見つからなかった場合 + * @throws IOException 入出力が失敗した場合 + * @see #getBuildDir(String) + */ + public static File getBuildDir(Class<?> clazz) throws ResourceNotFoundException, IOException { + return getBuildDir(getResourcePath(clazz)); + } + + /** + * クラスファイルが置かれているルートディレクトリを取得する。 + * + * @param path パス + * @return ルートディレクトリ + * @throws ResourceNotFoundException リソースが見つからなかった場合 + * @throws IOException 入出力が失敗した場合 + */ + public static File getBuildDir(String path) throws ResourceNotFoundException, IOException { + File dir = null; + URL url = getResource(path); + if ("file".equals(url.getProtocol())) { + int num = path.split("/").length; + dir = new File(getFileName(url)); + for (int i = 0; i < num; ++i, dir = dir.getParentFile()) { + // nop + } + } else { + dir = new File(JarFileUtil.toJarFilePath(url)); + } + return dir; + } + + /** + * クラスファイルが置かれているルートディレクトリを取得する。 + * + * @param clazz クラス + * @return ルートディレクトリ + * @see #getBuildDir(String) + */ + public static File getBuildDirNoException(Class<?> clazz) { + try { + File buildDir = ResourceUtil.getBuildDir(clazz); + return buildDir; + } catch (ResourceNotFoundException ignore) { + return null; + } catch (IOException ignore) { + return null; + } + } + + /** + * クラスローダを取得する。 + * + * @return クラスローダ + */ + public static ClassLoader getClassLoader() { + return Thread.currentThread().getContextClassLoader(); + } + + /** + * 拡張子を取得する。 + * + * @param path パス + * @return 拡張子 + */ + public static String getExtension(String path) { + int extPos = path.lastIndexOf("."); + if (extPos >= 0) { + return path.substring(extPos + 1); + } + return null; + } + + /** + * ファイルを取得する。 + * + * @param url URL + * @return ファイル + * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされていない場合 + */ + public static File getFile(URL url) throws UnsupportedEncodingException { + File file = new File(getFileName(url)); + if (file.exists()) { + return file; + } + return null; + } + + /** + * ファイル名を取得する。 + * + * @param url URL + * @return ファイル名 + * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされていない場合 + */ + public static String getFileName(URL url) throws UnsupportedEncodingException { + String s = url.getFile(); + return URLUtil.decode(s, "UTF8"); + } + + /** + * プロパティファイルを取得する。 + * + * @param path パス + * @return プロパティファイル + * @throws IOException 入出力が失敗した場合 + * @throws ResourceNotFoundException リソースが見つからなかった場合 + */ + public static Properties getProperties(String path) throws ResourceNotFoundException, IOException { + Properties props = new Properties(); + InputStream is = getResourceAsStream(path); + + props.load(is); + return props; + + } + + /** + * リソースを取得する。 + * + * @param path パス + * @return リソース + * @throws ResourceNotFoundException リソースが見つからなかった場合 + * @see #getResource(String, String) + */ + public static URL getResource(String path) throws ResourceNotFoundException { + return getResource(path, null); + } + + /** + * リソースを取得する。 + * + * @param path パス + * @param extension 拡張子 + * @return リソース + * @throws ResourceNotFoundException リソースが見つからなかった場合 + */ + public static URL getResource(String path, String extension) throws ResourceNotFoundException { + URL url = getResourceNoException(path, extension); + if (url != null) { + return url; + } + throw new ResourceNotFoundException(getResourcePath(path, extension)); + } + + /** + * リソースをファイルで取得する。 + * + * @param path パス + * @return ファイル + * @throws ResourceNotFoundException リソースが見つからなかった場合 + * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされていない場合 + * @see #getResourceAsFile(String, String) + */ + public static File getResourceAsFile(String path) throws ResourceNotFoundException, UnsupportedEncodingException { + return getResourceAsFile(path, null); + } + + /** + * リソースをファイルで取得する。 + * + * @param path パス + * @param extension 拡張子 + * @return ファイル + * @throws ResourceNotFoundException リソースが見つからなかった場合 + * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされていない場合 + * @see #getFile(URL) + */ + public static File getResourceAsFile(String path, String extension) throws ResourceNotFoundException, + UnsupportedEncodingException { + return getFile(getResource(path, extension)); + } + + /** + * リソースをファイルで取得する。 + * <p> + * リソースが見つからない場合は<code>null</code>。 + * </p> + * + * @param clazz クラス + * @return ファイル + * @see #getResourceAsFileNoException(String) + */ + public static File getResourceAsFileNoException(Class<?> clazz) { + return getResourceAsFileNoException(getResourcePath(clazz)); + } + + /** + * リソースをファイルで取得する。 + * <p> + * リソースが見つからない場合は<code>null</code>。 + * </p> + * + * @param path パス + * @return ファイル + * @see #getResourceNoException(String) + */ + public static File getResourceAsFileNoException(String path) { + URL url = getResourceNoException(path); + if (url == null) { + return null; + } + try { + return getFile(url); + } catch (UnsupportedEncodingException e) { + return null; + } + } + + /** + * リソースをストリームで取得する。 + * + * @param path パス + * @return ストリーム + * @throws ResourceNotFoundException リソースが見つからなかった場合 + * @throws IOException 入出力が失敗した場合 + * @see #getResourceAsStream(String, String) + */ + public static InputStream getResourceAsStream(String path) throws ResourceNotFoundException, IOException { + return getResourceAsStream(path, null); + } + + /** + * リソースをストリームで取得する。 + * + * @param path パス + * @param extension 拡張子 + * @return ストリーム + * @throws ResourceNotFoundException リソースが見つからなかった場合 + * @throws IOException 入出力が失敗した場合 + * @see #getResource(String, String) + */ + public static InputStream getResourceAsStream(String path, String extension) throws ResourceNotFoundException, + IOException { + URL url = getResource(path, extension); + return URLUtil.openStream(url); + } + + /** + * リソースをストリームで取得する。 + * <p> + * リソースが見つからなかった場合は<code>null</code>。 + * </p> + * + * @param path パス + * @return ストリーム + * @see #getResourceAsStreamNoException(String, String) + */ + public static InputStream getResourceAsStreamNoException(String path) { + return getResourceAsStreamNoException(path, null); + } + + /** + * リソースをストリームとして取得する。 + * <p> + * リソースが見つからなかった場合は<code>null</code>。 + * </p> + * + * @param path パス + * @param extension 拡張子 + * @return ストリーム + * @see #getResourceNoException(String, String) + */ + public static InputStream getResourceAsStreamNoException(String path, String extension) { + URL url = getResourceNoException(path, extension); + if (url == null) { + return null; + } + try { + return url.openStream(); + } catch (final IOException e) { + return null; + } + } + + /** + * リソースを取得する。 + * <p> + * 見つからなかった場合は<code>null</code>を返します。 + * </p> + * + * @param path パス + * @return リソース + * @see #getResourceNoException(String, String) + */ + public static URL getResourceNoException(String path) { + return getResourceNoException(path, null); + } + + /** + * リソースを取得する。 + * <p> + * 見つからなかった場合は<code>null</code>。 + * </p> + * + * @param path パス + * @param extension 拡張子 + * @return リソース + * @see #getResourceNoException(String, String, ClassLoader) + */ + public static URL getResourceNoException(String path, String extension) { + return getResourceNoException(path, extension, Thread.currentThread().getContextClassLoader()); + } + + /** + * リソースを取得する。 + * <p> + * 見つからなかった場合は<code>null</code>。 + * </p> + * + * @param path パス + * @param extension 拡張子 + * @param loader クラスローダ + * @return リソース + * @see #getResourcePath(String, String) + */ + public static URL getResourceNoException(String path, String extension, ClassLoader loader) { + if (path == null || loader == null) { + return null; + } + path = getResourcePath(path, extension); + return loader.getResource(path); + } + + /** + * リソースパスを取得する。 + * + * @param clazz クラス + * @return リソースパス + */ + public static String getResourcePath(Class<?> clazz) { + return clazz.getName().replace('.', '/') + ".class"; + } + + /** + * リソースパスを取得する。 + * + * @param path パス + * @param extension 拡張子 + * @return リソースパス + */ + public static String getResourcePath(String path, String extension) { + if (extension == null) { + return path; + } + extension = "." + extension; + if (path.endsWith(extension)) { + return path; + } + return path.replace('.', '/') + extension; + } + + /** + * リソースの存在有無を取得する。 + * + * @param path パス + * @return リソースが存在するかどうか + * @see #getResourceNoException(String) + */ + public static boolean isExist(String path) { + return getResourceNoException(path) != null; + } + + /** + * 拡張子を除去する。 + * + * @param path パス + * @return 取り除いた後の結果 + */ + public static String removeExtension(String path) { + int extPos = path.lastIndexOf("."); + if (extPos >= 0) { + return path.substring(0, extPos); + } + return path; + } + + /** + * 外部形式に変換する。 + * + * @param url URL + * @return 外部形式 + * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされていない場合 + */ + public static String toExternalForm(URL url) throws UnsupportedEncodingException { + String s = url.toExternalForm(); + return URLUtil.decode(s, "UTF8"); + } + + private ResourceUtil() { + throw new JiemamyError("不到達ポイント"); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourcesUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourcesUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourcesUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,436 +1,436 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.jar.JarFile; - -import org.apache.commons.lang.StringUtils; - -import org.jiemamy.exception.JiemamyError; -import org.jiemamy.utils.ClassTraversal.ClassHandler; -import org.jiemamy.utils.ResourceTraversal.ResourceHandler; - -/** - * ファイルシステム上やJarファイル中に展開されているリソースの集まりを扱うユーティリティクラス。 - * - * @author j5ik2o - */ -public final class ResourcesUtil { - - /** - * ファイルシステム上のリソースの集まりを扱うオブジェクト。 - * - * @author j5ik2o - */ - public static class FileSystemResources implements Resources { - - /** ベースディレクトリです。 */ - protected final File baseDir; - - /** ルートパッケージです。 */ - protected final String rootPackage; - - /** ルートディレクトリです。 */ - protected final String rootDir; - - - /** - * インスタンスを構築します。 - * - * @param baseDir ベースディレクトリ - * @param rootPackage ルートパッケージ - * @param rootDir ルートディレクトリ - */ - public FileSystemResources(final File baseDir, final String rootPackage, final String rootDir) { - this.baseDir = baseDir; - this.rootPackage = rootPackage; - this.rootDir = rootDir; - } - - /** - * インスタンスを生成する。 - * - * @param url ディレクトリを表すURL - * @param rootPackage ルートパッケージ - * @param rootDir ルートディレクトリ - * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされてない場合 - */ - public FileSystemResources(final URL url, final String rootPackage, final String rootDir) - throws UnsupportedEncodingException { - this(URLUtil.toFile(url), rootPackage, rootDir); - } - - public void close() { - // nothing to do - } - - public void forEach(final ClassHandler handler) throws TraversalHandlerException { - ClassTraversal.forEach(baseDir, rootPackage, handler); - } - - public void forEach(final ResourceHandler handler) throws IOException, TraversalHandlerException { - ResourceTraversal.forEach(baseDir, rootDir, handler); - } - - public boolean isExistClass(final String className) { - final File file = new File(baseDir, toClassFile(ClassUtil.concatName(rootPackage, className))); - return file.exists(); - } - - } - - /** - * Jarファイル中のリソースの集まりを扱うオブジェクト。 - * - * @author j5ik2o - */ - public static class JarFileResources implements Resources { - - /** Jarファイルです。 */ - protected final JarFile jarFile; - - /** ルートパッケージです。 */ - protected final String rootPackage; - - /** ルートディレクトリです。 */ - protected final String rootDir; - - - /** - * インスタンスを生成する。 - * - * @param jarFile Jarファイル - * @param rootPackage ルートパッケージ - * @param rootDir ルートディレクトリ - */ - public JarFileResources(final JarFile jarFile, final String rootPackage, final String rootDir) { - this.jarFile = jarFile; - this.rootPackage = rootPackage; - this.rootDir = rootDir; - } - - /** - * インスタンスを生成する。 - * - * @param url Jarファイルを表すURL - * @param rootPackage ルートパッケージ - * @param rootDir ルートディレクトリ - * @throws IOException 入出力エラーが発生した場合 - */ - public JarFileResources(final URL url, final String rootPackage, final String rootDir) throws IOException { - this(JarFileUtil.toJarFile(url), rootPackage, rootDir); - } - - public void close() throws IOException { - JarFileUtil.close(jarFile); - } - - public void forEach(final ClassHandler handler) throws TraversalHandlerException { - ClassTraversal.forEach(jarFile, new ClassHandler() { - - public void processClass(String packageName, String shortClassName) throws TraversalHandlerException { - if (rootPackage == null || (packageName != null && packageName.startsWith(rootPackage))) { - handler.processClass(packageName, shortClassName); - } - } - }); - } - - public void forEach(final ResourceHandler handler) throws IOException, TraversalHandlerException { - ResourceTraversal.forEach(jarFile, new ResourceHandler() { - - public void processResource(String path, InputStream is) throws TraversalHandlerException { - if (rootDir == null || path.startsWith(rootDir)) { - handler.processResource(path, is); - } - } - }); - } - - public boolean isExistClass(final String className) { - return jarFile.getEntry(toClassFile(ClassUtil.concatName(rootPackage, className))) != null; - } - - } - - /** - * リソースの集まりを表すオブジェクト。 - * - * @author j5ik2o - */ - public interface Resources { - - /** - * リソースの後処理を行う。 - * @throws IOException 入出力が失敗した場合 - */ - void close() throws IOException; - - /** - * このインスタンスが扱うリソースの中に存在するクラスを探して - * {@link ClassHandler#processClass(String, String) ハンドラ}をコールバックする。 - * <p> - * インスタンス構築時にルートパッケージが指定されている場合は、 ルートパッケージ以下のクラスのみが対象となる。 - * </p> - * - * @param handler ハンドラ - * @throws TraversalHandlerException ハンドラの処理が失敗した場合 - */ - void forEach(ClassHandler handler) throws TraversalHandlerException; - - /** - * このインスタンスが扱うリソースを探して - * {@link ResourceHandler#processResource(String, java.io.InputStream) - * ハンドラ}をコールバックする。 - * <p> - * インスタンス構築時にルートディレクトリが指定されている場合は、 ルートディレクトリ以下のリソースのみが対象となる。 - * </p> - * - * @param handler ハンドラ - * @throws IOException 入出力が失敗した場合 - * @throws TraversalHandlerException ハンドラの処理が失敗した場合 - */ - void forEach(ResourceHandler handler) throws IOException, TraversalHandlerException; - - /** - * 指定されたクラス名に対応するクラスファイルがこのインスタンスが扱うリソースの中に存在すれば<code>true</code>を取得する。 - * <p> - * インスタンス構築時にルートパッケージが指定されている場合、 指定されたクラス名はルートパッケージからの相対名として解釈する。 - * </p> - * - * @param className クラス名 - * @return 指定されたクラス名に対応するクラスファイルがこのインスタンスが扱うリソースの中に存在すれば - * <code>true</code> - */ - boolean isExistClass(final String className); - - } - - /** - * {@link Resources}のインスタンスを作成するファクトリ。 - * - * @author j5ik2o - */ - public interface ResourcesFactory { - - /** - * {@link Resources}のインスタンスを作成して返します。 - * - * @param url リソースを表すURL - * @param rootPackage ルートパッケージ - * @param rootDir ルートディレクトリ - * @return URLで表されたリソースを扱う{@link Resources} - * @throws IOException 入出力エラーが発生した場合 - */ - Resources create(URL url, String rootPackage, String rootDir) throws IOException; - } - - - /** 空の{@link Resources}の配列。 */ - private static final Resources[] EMPTY_ARRAY = new Resources[0]; - - /** URLのプロトコルをキー、{@link ResourcesFactory}を値とするマッピング。 */ - private static final Map<String, ResourcesFactory> RESOUCES_TYPE_FACTORIES = - new HashMap<String, ResourcesFactory>(); - - //private static final Logger logger = Logger.getLogger(ResourcesUtil.class); - - static { - addResourcesFactory("file", new ResourcesFactory() { - - public Resources create(final URL url, final String rootPackage, final String rootDir) { - try { - return new FileSystemResources(getBaseDir(url, rootDir), rootPackage, rootDir); - } catch (UnsupportedEncodingException e) { - return null; - } - } - }); - addResourcesFactory("jar", new ResourcesFactory() { - - public Resources create(final URL url, final String rootPackage, final String rootDir) throws IOException { - return new JarFileResources(url, rootPackage, rootDir); - } - }); - addResourcesFactory("zip", new ResourcesFactory() { - - public Resources create(final URL url, final String rootPackage, final String rootDir) throws IOException { - return new JarFileResources(JarFileUtil.create(new File(ZipFileUtil.toZipFilePath(url))), rootPackage, - rootDir); - } - }); - addResourcesFactory("code-source", new ResourcesFactory() { - - public Resources create(final URL url, final String rootPackage, final String rootDir) throws IOException { - return new JarFileResources(URLUtil.create("jar:file:" + url.getPath()), rootPackage, rootDir); - } - }); - } - - - /** - * {@link ResourcesFactory}を追加する。 - * - * @param protocol URLのプロトコル - * @param factory プロトコルに対応する{@link Resources}のファクトリ - */ - public static void addResourcesFactory(final String protocol, ResourcesFactory factory) { - RESOUCES_TYPE_FACTORIES.put(protocol, factory); - } - - /** - * ファイルを表すURLからルートパッケージの上位となるベースディレクトリを取得する。 - * - * @param url ファイルを表すURL - * @param baseName ベース名 - * @return ルートパッケージの上位となるベースディレクトリ - * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされてない場合 - */ - protected static File getBaseDir(final URL url, final String baseName) throws UnsupportedEncodingException { - File file = URLUtil.toFile(url); - final String[] paths = StringUtils.split(baseName, "/"); - for (int i = 0; i < paths.length; ++i) { - file = file.getParentFile(); - } - return file; - } - - /** - * 指定のクラスを基点とするリソースの集まりを扱う{@link Resources}を取得する。 - * <p> - * このメソッドが返す{@link Resources}は、指定されたクラスをFQNで参照可能なパスをルートとします。 例えば指定されたクラスが - * <code>foo.Bar</code>で、そのクラスファイルが<code>classes/foo/Bar.class</code>の場合、 - * このメソッドが返す{@link Resources}は<code>classes</code>ディレクトリ以下のリソースの集合を扱う。 - * </p> - * - * @param referenceClass 基点となるクラス - * @return 指定のクラスを基点とするリソースの集まりを扱う{@link Resources} - * @throws IOException 入出力エラーが発生した場合 - * @throws ResourceNotFoundException リソースが見つからなかった場合 - */ - public static Resources getResourcesType(final Class<?> referenceClass) throws IOException, - ResourceNotFoundException { - final URL url = ResourceUtil.getResource(toClassFile(referenceClass.getName())); - final String[] path = referenceClass.getName().split("\\."); - String baseUrl = url.toExternalForm(); - for (int i = 0; i < path.length; ++i) { - int pos = baseUrl.lastIndexOf('/'); - baseUrl = baseUrl.substring(0, pos); - } - return getResourcesType(URLUtil.create(baseUrl + '/'), null, null); - } - - /** - * 指定のディレクトリを基点とするリソースの集まりを扱う{@link Resources}を取得する。 - * - * @param rootDir ルートディレクトリ - * @return 指定のディレクトリを基点とするリソースの集まりを扱う{@link Resources} - * @throws IOException 入出力エラーが発生した場合 - * @throws ResourceNotFoundException リソースが見つからなかった場合 - */ - public static Resources getResourcesType(final String rootDir) throws IOException, ResourceNotFoundException { - final URL url = ResourceUtil.getResource(rootDir.endsWith("/") ? rootDir : rootDir + '/'); - return getResourcesType(url, null, rootDir); - } - - /** - * URLを扱う{@link Resources}を取得する。 - * <p> - * URLのプロトコルが未知の場合は<code>null</code>。 - * </p> - * - * @param url リソースのURL - * @param rootPackage ルートパッケージ - * @param rootDir ルートディレクトリ - * @return URLを扱う{@link Resources} - * @throws IOException 入出力エラーが発生した場合 - */ - protected static Resources getResourcesType(final URL url, final String rootPackage, final String rootDir) - throws IOException { - final ResourcesFactory factory = RESOUCES_TYPE_FACTORIES.get(URLUtil.toCanonicalProtocol(url.getProtocol())); - if (factory != null) { - return factory.create(url, rootPackage, rootDir); - } - return null; - } - - /** - * 指定のルートパッケージを基点とするリソースの集まりを扱う{@link Resources}の配列を取得する。 - * - * @param rootPackage ルートパッケージ - * @return 指定のルートパッケージを基点とするリソースの集まりを扱う{@link Resources}の配列 - * @throws IOException 入出力エラーが発生した場合 - */ - public static Resources[] getResourcesTypes(final String rootPackage) throws IOException { - if (StringUtils.isEmpty(rootPackage)) { - return EMPTY_ARRAY; - } - - final String baseName = toDirectoryName(rootPackage); - final List<Resources> list = new ArrayList<Resources>(); - for (final Iterator<URL> it = ClassLoaderUtil.getResources(baseName); it.hasNext();) { - final URL url = it.next(); - final Resources resourcesType = getResourcesType(url, rootPackage, baseName); - if (resourcesType != null) { - list.add(resourcesType); - } - } - if (list.isEmpty()) { - return EMPTY_ARRAY; - } - return list.toArray(new Resources[list.size()]); - } - - /** - * クラス名をクラスファイルのパス名に変換する。 - * - * @param className クラス名 - * @return クラスファイルのパス名 - */ - protected static String toClassFile(final String className) { - return className.replace('.', '/') + ".class"; - } - - /** - * パッケージ名をディレクトリ名に変換する。 - * - * @param packageName パッケージ名 - * @return ディレクトリ名 - */ - protected static String toDirectoryName(final String packageName) { - if (StringUtils.isEmpty(packageName)) { - return null; - } - return packageName.replace('.', '/') + '/'; - } - - private ResourcesUtil() { - throw new JiemamyError("不到達ポイント"); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.jar.JarFile; + +import org.apache.commons.lang.StringUtils; + +import org.jiemamy.exception.JiemamyError; +import org.jiemamy.utils.ClassTraversal.ClassHandler; +import org.jiemamy.utils.ResourceTraversal.ResourceHandler; + +/** + * ファイルシステム上やJarファイル中に展開されているリソースの集まりを扱うユーティリティクラス。 + * + * @author j5ik2o + */ +public final class ResourcesUtil { + + /** + * ファイルシステム上のリソースの集まりを扱うオブジェクト。 + * + * @author j5ik2o + */ + public static class FileSystemResources implements Resources { + + /** ベースディレクトリです。 */ + protected final File baseDir; + + /** ルートパッケージです。 */ + protected final String rootPackage; + + /** ルートディレクトリです。 */ + protected final String rootDir; + + + /** + * インスタンスを構築します。 + * + * @param baseDir ベースディレクトリ + * @param rootPackage ルートパッケージ + * @param rootDir ルートディレクトリ + */ + public FileSystemResources(final File baseDir, final String rootPackage, final String rootDir) { + this.baseDir = baseDir; + this.rootPackage = rootPackage; + this.rootDir = rootDir; + } + + /** + * インスタンスを生成する。 + * + * @param url ディレクトリを表すURL + * @param rootPackage ルートパッケージ + * @param rootDir ルートディレクトリ + * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされてない場合 + */ + public FileSystemResources(final URL url, final String rootPackage, final String rootDir) + throws UnsupportedEncodingException { + this(URLUtil.toFile(url), rootPackage, rootDir); + } + + public void close() { + // nothing to do + } + + public void forEach(final ClassHandler handler) throws TraversalHandlerException { + ClassTraversal.forEach(baseDir, rootPackage, handler); + } + + public void forEach(final ResourceHandler handler) throws IOException, TraversalHandlerException { + ResourceTraversal.forEach(baseDir, rootDir, handler); + } + + public boolean isExistClass(final String className) { + final File file = new File(baseDir, toClassFile(ClassUtil.concatName(rootPackage, className))); + return file.exists(); + } + + } + + /** + * Jarファイル中のリソースの集まりを扱うオブジェクト。 + * + * @author j5ik2o + */ + public static class JarFileResources implements Resources { + + /** Jarファイルです。 */ + protected final JarFile jarFile; + + /** ルートパッケージです。 */ + protected final String rootPackage; + + /** ルートディレクトリです。 */ + protected final String rootDir; + + + /** + * インスタンスを生成する。 + * + * @param jarFile Jarファイル + * @param rootPackage ルートパッケージ + * @param rootDir ルートディレクトリ + */ + public JarFileResources(final JarFile jarFile, final String rootPackage, final String rootDir) { + this.jarFile = jarFile; + this.rootPackage = rootPackage; + this.rootDir = rootDir; + } + + /** + * インスタンスを生成する。 + * + * @param url Jarファイルを表すURL + * @param rootPackage ルートパッケージ + * @param rootDir ルートディレクトリ + * @throws IOException 入出力エラーが発生した場合 + */ + public JarFileResources(final URL url, final String rootPackage, final String rootDir) throws IOException { + this(JarFileUtil.toJarFile(url), rootPackage, rootDir); + } + + public void close() throws IOException { + JarFileUtil.close(jarFile); + } + + public void forEach(final ClassHandler handler) throws TraversalHandlerException { + ClassTraversal.forEach(jarFile, new ClassHandler() { + + public void processClass(String packageName, String shortClassName) throws TraversalHandlerException { + if (rootPackage == null || (packageName != null && packageName.startsWith(rootPackage))) { + handler.processClass(packageName, shortClassName); + } + } + }); + } + + public void forEach(final ResourceHandler handler) throws IOException, TraversalHandlerException { + ResourceTraversal.forEach(jarFile, new ResourceHandler() { + + public void processResource(String path, InputStream is) throws TraversalHandlerException { + if (rootDir == null || path.startsWith(rootDir)) { + handler.processResource(path, is); + } + } + }); + } + + public boolean isExistClass(final String className) { + return jarFile.getEntry(toClassFile(ClassUtil.concatName(rootPackage, className))) != null; + } + + } + + /** + * リソースの集まりを表すオブジェクト。 + * + * @author j5ik2o + */ + public interface Resources { + + /** + * リソースの後処理を行う。 + * @throws IOException 入出力が失敗した場合 + */ + void close() throws IOException; + + /** + * このインスタンスが扱うリソースの中に存在するクラスを探して + * {@link ClassHandler#processClass(String, String) ハンドラ}をコールバックする。 + * <p> + * インスタンス構築時にルートパッケージが指定されている場合は、 ルートパッケージ以下のクラスのみが対象となる。 + * </p> + * + * @param handler ハンドラ + * @throws TraversalHandlerException ハンドラの処理が失敗した場合 + */ + void forEach(ClassHandler handler) throws TraversalHandlerException; + + /** + * このインスタンスが扱うリソースを探して + * {@link ResourceHandler#processResource(String, java.io.InputStream) + * ハンドラ}をコールバックする。 + * <p> + * インスタンス構築時にルートディレクトリが指定されている場合は、 ルートディレクトリ以下のリソースのみが対象となる。 + * </p> + * + * @param handler ハンドラ + * @throws IOException 入出力が失敗した場合 + * @throws TraversalHandlerException ハンドラの処理が失敗した場合 + */ + void forEach(ResourceHandler handler) throws IOException, TraversalHandlerException; + + /** + * 指定されたクラス名に対応するクラスファイルがこのインスタンスが扱うリソースの中に存在すれば<code>true</code>を取得する。 + * <p> + * インスタンス構築時にルートパッケージが指定されている場合、 指定されたクラス名はルートパッケージからの相対名として解釈する。 + * </p> + * + * @param className クラス名 + * @return 指定されたクラス名に対応するクラスファイルがこのインスタンスが扱うリソースの中に存在すれば + * <code>true</code> + */ + boolean isExistClass(final String className); + + } + + /** + * {@link Resources}のインスタンスを作成するファクトリ。 + * + * @author j5ik2o + */ + public interface ResourcesFactory { + + /** + * {@link Resources}のインスタンスを作成して返します。 + * + * @param url リソースを表すURL + * @param rootPackage ルートパッケージ + * @param rootDir ルートディレクトリ + * @return URLで表されたリソースを扱う{@link Resources} + * @throws IOException 入出力エラーが発生した場合 + */ + Resources create(URL url, String rootPackage, String rootDir) throws IOException; + } + + + /** 空の{@link Resources}の配列。 */ + private static final Resources[] EMPTY_ARRAY = new Resources[0]; + + /** URLのプロトコルをキー、{@link ResourcesFactory}を値とするマッピング。 */ + private static final Map<String, ResourcesFactory> RESOUCES_TYPE_FACTORIES = + new HashMap<String, ResourcesFactory>(); + + //private static final Logger logger = Logger.getLogger(ResourcesUtil.class); + + static { + addResourcesFactory("file", new ResourcesFactory() { + + public Resources create(final URL url, final String rootPackage, final String rootDir) { + try { + return new FileSystemResources(getBaseDir(url, rootDir), rootPackage, rootDir); + } catch (UnsupportedEncodingException e) { + return null; + } + } + }); + addResourcesFactory("jar", new ResourcesFactory() { + + public Resources create(final URL url, final String rootPackage, final String rootDir) throws IOException { + return new JarFileResources(url, rootPackage, rootDir); + } + }); + addResourcesFactory("zip", new ResourcesFactory() { + + public Resources create(final URL url, final String rootPackage, final String rootDir) throws IOException { + return new JarFileResources(JarFileUtil.create(new File(ZipFileUtil.toZipFilePath(url))), rootPackage, + rootDir); + } + }); + addResourcesFactory("code-source", new ResourcesFactory() { + + public Resources create(final URL url, final String rootPackage, final String rootDir) throws IOException { + return new JarFileResources(URLUtil.create("jar:file:" + url.getPath()), rootPackage, rootDir); + } + }); + } + + + /** + * {@link ResourcesFactory}を追加する。 + * + * @param protocol URLのプロトコル + * @param factory プロトコルに対応する{@link Resources}のファクトリ + */ + public static void addResourcesFactory(final String protocol, ResourcesFactory factory) { + RESOUCES_TYPE_FACTORIES.put(protocol, factory); + } + + /** + * ファイルを表すURLからルートパッケージの上位となるベースディレクトリを取得する。 + * + * @param url ファイルを表すURL + * @param baseName ベース名 + * @return ルートパッケージの上位となるベースディレクトリ + * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされてない場合 + */ + protected static File getBaseDir(final URL url, final String baseName) throws UnsupportedEncodingException { + File file = URLUtil.toFile(url); + final String[] paths = StringUtils.split(baseName, "/"); + for (int i = 0; i < paths.length; ++i) { + file = file.getParentFile(); + } + return file; + } + + /** + * 指定のクラスを基点とするリソースの集まりを扱う{@link Resources}を取得する。 + * <p> + * このメソッドが返す{@link Resources}は、指定されたクラスをFQNで参照可能なパスをルートとします。 例えば指定されたクラスが + * <code>foo.Bar</code>で、そのクラスファイルが<code>classes/foo/Bar.class</code>の場合、 + * このメソッドが返す{@link Resources}は<code>classes</code>ディレクトリ以下のリソースの集合を扱う。 + * </p> + * + * @param referenceClass 基点となるクラス + * @return 指定のクラスを基点とするリソースの集まりを扱う{@link Resources} + * @throws IOException 入出力エラーが発生した場合 + * @throws ResourceNotFoundException リソースが見つからなかった場合 + */ + public static Resources getResourcesType(final Class<?> referenceClass) throws IOException, + ResourceNotFoundException { + final URL url = ResourceUtil.getResource(toClassFile(referenceClass.getName())); + final String[] path = referenceClass.getName().split("\\."); + String baseUrl = url.toExternalForm(); + for (int i = 0; i < path.length; ++i) { + int pos = baseUrl.lastIndexOf('/'); + baseUrl = baseUrl.substring(0, pos); + } + return getResourcesType(URLUtil.create(baseUrl + '/'), null, null); + } + + /** + * 指定のディレクトリを基点とするリソースの集まりを扱う{@link Resources}を取得する。 + * + * @param rootDir ルートディレクトリ + * @return 指定のディレクトリを基点とするリソースの集まりを扱う{@link Resources} + * @throws IOException 入出力エラーが発生した場合 + * @throws ResourceNotFoundException リソースが見つからなかった場合 + */ + public static Resources getResourcesType(final String rootDir) throws IOException, ResourceNotFoundException { + final URL url = ResourceUtil.getResource(rootDir.endsWith("/") ? rootDir : rootDir + '/'); + return getResourcesType(url, null, rootDir); + } + + /** + * URLを扱う{@link Resources}を取得する。 + * <p> + * URLのプロトコルが未知の場合は<code>null</code>。 + * </p> + * + * @param url リソースのURL + * @param rootPackage ルートパッケージ + * @param rootDir ルートディレクトリ + * @return URLを扱う{@link Resources} + * @throws IOException 入出力エラーが発生した場合 + */ + protected static Resources getResourcesType(final URL url, final String rootPackage, final String rootDir) + throws IOException { + final ResourcesFactory factory = RESOUCES_TYPE_FACTORIES.get(URLUtil.toCanonicalProtocol(url.getProtocol())); + if (factory != null) { + return factory.create(url, rootPackage, rootDir); + } + return null; + } + + /** + * 指定のルートパッケージを基点とするリソースの集まりを扱う{@link Resources}の配列を取得する。 + * + * @param rootPackage ルートパッケージ + * @return 指定のルートパッケージを基点とするリソースの集まりを扱う{@link Resources}の配列 + * @throws IOException 入出力エラーが発生した場合 + */ + public static Resources[] getResourcesTypes(final String rootPackage) throws IOException { + if (StringUtils.isEmpty(rootPackage)) { + return EMPTY_ARRAY; + } + + final String baseName = toDirectoryName(rootPackage); + final List<Resources> list = new ArrayList<Resources>(); + for (final Iterator<URL> it = ClassLoaderUtil.getResources(baseName); it.hasNext();) { + final URL url = it.next(); + final Resources resourcesType = getResourcesType(url, rootPackage, baseName); + if (resourcesType != null) { + list.add(resourcesType); + } + } + if (list.isEmpty()) { + return EMPTY_ARRAY; + } + return list.toArray(new Resources[list.size()]); + } + + /** + * クラス名をクラスファイルのパス名に変換する。 + * + * @param className クラス名 + * @return クラスファイルのパス名 + */ + protected static String toClassFile(final String className) { + return className.replace('.', '/') + ".class"; + } + + /** + * パッケージ名をディレクトリ名に変換する。 + * + * @param packageName パッケージ名 + * @return ディレクトリ名 + */ + protected static String toDirectoryName(final String packageName) { + if (StringUtils.isEmpty(packageName)) { + return null; + } + return packageName.replace('.', '/') + '/'; + } + + private ResourcesUtil() { + throw new JiemamyError("不到達ポイント"); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourcesUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResultSetUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResultSetUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResultSetUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,245 +1,245 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/04/14 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.InputStream; -import java.sql.ResultSet; -import java.sql.SQLException; - -/** - * {@link ResultSet}のユーティリティクラス。 - * - * @author daisuke - */ -public final class ResultSetUtil { - - /** - * {@link ResultSet#getAsciiStream(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は{@code null} - */ - public static InputStream getAsciiStream(ResultSet rs, String columnName) { - try { - return rs.getAsciiStream(columnName); - } catch (SQLException e) { - return null; - } - } - - /** - * {@link ResultSet#getBinaryStream(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は{@code null} - */ - public static InputStream getBinaryStream(ResultSet rs, String columnName) { - try { - return rs.getAsciiStream(columnName); - } catch (SQLException e) { - return null; - } - } - - /** - * {@link ResultSet#getBoolean(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は{@code false} - */ - public static boolean getBoolean(ResultSet rs, String columnName) { - try { - return rs.getBoolean(columnName); - } catch (SQLException e) { - return false; - } - } - - /** - * {@link ResultSet#getByte(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は{@code 0} - */ - public static byte getByte(ResultSet rs, String columnName) { - try { - return rs.getByte(columnName); - } catch (SQLException e) { - return 0; - } - } - - /** - * {@link ResultSet#getBytes(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は長さ0の配列 - */ - public static byte[] getBytes(ResultSet rs, String columnName) { - try { - return rs.getBytes(columnName); - } catch (SQLException e) { - return new byte[0]; - } - } - - /** - * {@link ResultSet#getDate(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は{@code null} - */ - public static java.sql.Date getDate(ResultSet rs, String columnName) { - try { - return rs.getDate(columnName); - } catch (SQLException e) { - return null; - } - } - - /** - * {@link ResultSet#getDouble(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は{@code 0} - */ - public static double getDouble(ResultSet rs, String columnName) { - try { - return rs.getDouble(columnName); - } catch (SQLException e) { - return 0; - } - } - - /** - * {@link ResultSet#getFloat(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は{@code 0} - */ - public static float getFloat(ResultSet rs, String columnName) { - try { - return rs.getFloat(columnName); - } catch (SQLException e) { - return 0; - } - } - - /** - * {@link ResultSet#getInt(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は{@code 0} - */ - public static int getInt(ResultSet rs, String columnName) { - try { - return rs.getInt(columnName); - } catch (SQLException e) { - return 0; - } - } - - /** - * {@link ResultSet#getLong(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は{@code 0} - */ - public static long getLong(ResultSet rs, String columnName) { - try { - return rs.getLong(columnName); - } catch (SQLException e) { - return 0; - } - } - - /** - * {@link ResultSet#getShort(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は{@code 0} - */ - public static short getShort(ResultSet rs, String columnName) { - try { - return rs.getShort(columnName); - } catch (SQLException e) { - return 0; - } - } - - /** - * {@link ResultSet#getString(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は{@code null} - */ - public static String getString(ResultSet rs, String columnName) { - try { - return rs.getString(columnName); - } catch (SQLException e) { - return null; - } - } - - /** - * {@link ResultSet#getTime(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は{@code null} - */ - public static java.sql.Time getTime(ResultSet rs, String columnName) { - try { - return rs.getTime(columnName); - } catch (SQLException e) { - return null; - } - } - - /** - * {@link ResultSet#getTimestamp(String)}の結果を取得する。 - * - * @param rs {@link ResultSet} - * @param columnName カラム名 - * @return 結果. {@link SQLException}が発生した場合は{@code null} - */ - public static java.sql.Timestamp getTimestamp(ResultSet rs, String columnName) { - try { - return rs.getTimestamp(columnName); - } catch (SQLException e) { - return null; - } - } - - private ResultSetUtil() { - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/04/14 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * {@link ResultSet}のユーティリティクラス。 + * + * @author daisuke + */ +public final class ResultSetUtil { + + /** + * {@link ResultSet#getAsciiStream(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は{@code null} + */ + public static InputStream getAsciiStream(ResultSet rs, String columnName) { + try { + return rs.getAsciiStream(columnName); + } catch (SQLException e) { + return null; + } + } + + /** + * {@link ResultSet#getBinaryStream(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は{@code null} + */ + public static InputStream getBinaryStream(ResultSet rs, String columnName) { + try { + return rs.getAsciiStream(columnName); + } catch (SQLException e) { + return null; + } + } + + /** + * {@link ResultSet#getBoolean(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は{@code false} + */ + public static boolean getBoolean(ResultSet rs, String columnName) { + try { + return rs.getBoolean(columnName); + } catch (SQLException e) { + return false; + } + } + + /** + * {@link ResultSet#getByte(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は{@code 0} + */ + public static byte getByte(ResultSet rs, String columnName) { + try { + return rs.getByte(columnName); + } catch (SQLException e) { + return 0; + } + } + + /** + * {@link ResultSet#getBytes(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は長さ0の配列 + */ + public static byte[] getBytes(ResultSet rs, String columnName) { + try { + return rs.getBytes(columnName); + } catch (SQLException e) { + return new byte[0]; + } + } + + /** + * {@link ResultSet#getDate(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は{@code null} + */ + public static java.sql.Date getDate(ResultSet rs, String columnName) { + try { + return rs.getDate(columnName); + } catch (SQLException e) { + return null; + } + } + + /** + * {@link ResultSet#getDouble(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は{@code 0} + */ + public static double getDouble(ResultSet rs, String columnName) { + try { + return rs.getDouble(columnName); + } catch (SQLException e) { + return 0; + } + } + + /** + * {@link ResultSet#getFloat(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は{@code 0} + */ + public static float getFloat(ResultSet rs, String columnName) { + try { + return rs.getFloat(columnName); + } catch (SQLException e) { + return 0; + } + } + + /** + * {@link ResultSet#getInt(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は{@code 0} + */ + public static int getInt(ResultSet rs, String columnName) { + try { + return rs.getInt(columnName); + } catch (SQLException e) { + return 0; + } + } + + /** + * {@link ResultSet#getLong(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は{@code 0} + */ + public static long getLong(ResultSet rs, String columnName) { + try { + return rs.getLong(columnName); + } catch (SQLException e) { + return 0; + } + } + + /** + * {@link ResultSet#getShort(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は{@code 0} + */ + public static short getShort(ResultSet rs, String columnName) { + try { + return rs.getShort(columnName); + } catch (SQLException e) { + return 0; + } + } + + /** + * {@link ResultSet#getString(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は{@code null} + */ + public static String getString(ResultSet rs, String columnName) { + try { + return rs.getString(columnName); + } catch (SQLException e) { + return null; + } + } + + /** + * {@link ResultSet#getTime(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は{@code null} + */ + public static java.sql.Time getTime(ResultSet rs, String columnName) { + try { + return rs.getTime(columnName); + } catch (SQLException e) { + return null; + } + } + + /** + * {@link ResultSet#getTimestamp(String)}の結果を取得する。 + * + * @param rs {@link ResultSet} + * @param columnName カラム名 + * @return 結果. {@link SQLException}が発生した場合は{@code null} + */ + public static java.sql.Timestamp getTimestamp(ResultSet rs, String columnName) { + try { + return rs.getTimestamp(columnName); + } catch (SQLException e) { + return null; + } + } + + private ResultSetUtil() { + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResultSetUtil.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/SqlExecuter.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/SqlExecuter.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/SqlExecuter.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,95 +1,95 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/03/31 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -import org.apache.commons.lang.Validate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * SQLを実行するクラス。 - * - * @author daisuke - * @deprecated クラス名のスペルミス。今後は {@link SqlExecutor} を使用してください。 - * @see SqlExecutor - */ - @ Deprecated -public class SqlExecuter { - - private static Logger logger = LoggerFactory.getLogger(SqlExecuter.class); - - private final Connection connection; - - - /** - * インスタンスを生成する。 - * - * @param connection コネクション - */ - public SqlExecuter(Connection connection) { - Validate.notNull(connection); - this.connection = connection; - } - - /** - * SQLを実行する。 - * - * @param sql 実行するSQL - * @return 結果の{@link ResultSet} - * @throws SQLException SQLの実行に失敗した場合 - */ - public ResultSet execute(String sql) throws SQLException { - logger.info(sql); - - connection.setAutoCommit(false); - - Statement statement = null; - ResultSet resultSet = null; - try { - statement = connection.createStatement(); - if (statement.execute(sql)) { - resultSet = statement.getResultSet(); - } - connection.commit(); - } finally { - JmIOUtil.closeQuietly(statement); - } - return resultSet; - } - -// * @param sql 実行するSQL -// */ -// public void executeIgnoreSqlException(String sql) { -// try { -// execute(sql); -// } catch (SQLException e) { -// logger.warn("SQLException ignored: " + e.getMessage()); -// try { -// connection.commit(); -// } catch (SQLException e2) { -// logger.error("SQLException ignored: " + e.getMessage()); -// } -// } -// } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/03/31 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import org.apache.commons.lang.Validate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * SQLを実行するクラス。 + * + * @author daisuke + * @deprecated クラス名のスペルミス。今後は {@link SqlExecutor} を使用してください。 + * @see SqlExecutor + */ + @ Deprecated +public class SqlExecuter { + + private static Logger logger = LoggerFactory.getLogger(SqlExecuter.class); + + private final Connection connection; + + + /** + * インスタンスを生成する。 + * + * @param connection コネクション + */ + public SqlExecuter(Connection connection) { + Validate.notNull(connection); + this.connection = connection; + } + + /** + * SQLを実行する。 + * + * @param sql 実行するSQL + * @return 結果の{@link ResultSet} + * @throws SQLException SQLの実行に失敗した場合 + */ + public ResultSet execute(String sql) throws SQLException { + logger.info(sql); + + connection.setAutoCommit(false); + + Statement statement = null; + ResultSet resultSet = null; + try { + statement = connection.createStatement(); + if (statement.execute(sql)) { + resultSet = statement.getResultSet(); + } + connection.commit(); + } finally { + JmIOUtil.closeQuietly(statement); + } + return resultSet; + } + +// * @param sql 実行するSQL +// */ +// public void executeIgnoreSqlException(String sql) { +// try { +// execute(sql); +// } catch (SQLException e) { +// logger.warn("SQLException ignored: " + e.getMessage()); +// try { +// connection.commit(); +// } catch (SQLException e2) { +// logger.error("SQLException ignored: " + e.getMessage()); +// } +// } +// } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/SqlExecuter.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/SqlExecutor.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/SqlExecutor.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/SqlExecutor.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,185 +1,185 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/05/22 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.Validate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * SQLを実行するクラス。 - * - * @author Keisuke.K - */ -public class SqlExecutor { - - private static Logger logger = LoggerFactory.getLogger(SqlExecutor.class); - - private static final char SINGLEQUOTE = '\''; - - private static final char SEMICOLON = ';'; - - private final Connection connection; - - private SqlExecutorHandler handler; - - private Reader in; - - - /** - * インスタンスを生成する。 - * - * @param connection コネクション - */ - public SqlExecutor(Connection connection) { - Validate.notNull(connection); - this.connection = connection; - } - - /** - * SQLを実行する。 - * - * @throws SQLException SQLの実行に失敗した場合 - * @throws IOException SQLデータの取得に失敗した場合 - */ - public void execute() throws SQLException, IOException { - StringBuilder builder = new StringBuilder(); - - boolean quotedFlag = false; - boolean execFlag = false; - int ch = in.read(); - while (ch != -1) { - switch (ch) { - case SINGLEQUOTE: - quotedFlag ^= true; - break; - case SEMICOLON: - execFlag = !quotedFlag; - break; - default: - builder.append((char) ch); - } - - if (execFlag) { - execute(builder.toString()); - builder.setLength(0); - } - - ch = in.read(); - } - } - - /** - * SQLを実行する。 - * - * @param sql 実行するSQL - * @throws SQLException SQLの実行に失敗した場合 - */ - public void execute(String sql) throws SQLException { - logger.info(sql); - - connection.setAutoCommit(false); - - Statement stmt = null; - ResultSet rs = null; - try { - stmt = connection.createStatement(); - - if (stmt.execute(sql)) { - rs = stmt.getResultSet(); - } - - if (handler != null) { - handler.sqlExecuted(sql, rs); - } - - connection.commit(); - } finally { - JmIOUtil.closeQuietly(rs); - JmIOUtil.closeQuietly(stmt); - } - } - - /** - * SQL実行後に呼び出すハンドラをセットする。 - * - * @param handler ハンドラ - */ - public void setHandler(SqlExecutorHandler handler) { - this.handler = handler; - } - - /** - * 実行するSQLを保持する入力ストリームをセットする。 - * - * @param is 実行するSQLを保持する入力ストリーム - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public void setInputStream(InputStream is) { - Validate.notNull(is); - in = new InputStreamReader(is); - } - - /** - * 実行するSQLを保持する入力ストリームをセットする。 - * - * @param in 実行するSQLを保持する入力ストリーム - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public void setReader(Reader in) { - Validate.notNull(in); - this.in = in; - } - - @Override - protected void finalize() throws Throwable { - IOUtils.closeQuietly(in); - - super.finalize(); - } - - - /** - * SQL実行クラスが、1つのSQLを実行後に呼び出すハンドラインタフェース。 - * - * @author Keisuke.K - */ - public interface SqlExecutorHandler { - - /** - * SQLが実行されると呼び出されるハンドラメソッド。 - * - * @param sql 実行したSQL - * @param rs 実行結果の {@link ResultSet}。SQLの実行結果が {@link ResultSet} とならないSQLの場合、<code>null</code>。 - */ - void sqlExecuted(String sql, ResultSet rs); - - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/05/22 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.Validate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * SQLを実行するクラス。 + * + * @author Keisuke.K + */ +public class SqlExecutor { + + private static Logger logger = LoggerFactory.getLogger(SqlExecutor.class); + + private static final char SINGLEQUOTE = '\''; + + private static final char SEMICOLON = ';'; + + private final Connection connection; + + private SqlExecutorHandler handler; + + private Reader in; + + + /** + * インスタンスを生成する。 + * + * @param connection コネクション + */ + public SqlExecutor(Connection connection) { + Validate.notNull(connection); + this.connection = connection; + } + + /** + * SQLを実行する。 + * + * @throws SQLException SQLの実行に失敗した場合 + * @throws IOException SQLデータの取得に失敗した場合 + */ + public void execute() throws SQLException, IOException { + StringBuilder builder = new StringBuilder(); + + boolean quotedFlag = false; + boolean execFlag = false; + int ch = in.read(); + while (ch != -1) { + switch (ch) { + case SINGLEQUOTE: + quotedFlag ^= true; + break; + case SEMICOLON: + execFlag = !quotedFlag; + break; + default: + builder.append((char) ch); + } + + if (execFlag) { + execute(builder.toString()); + builder.setLength(0); + } + + ch = in.read(); + } + } + + /** + * SQLを実行する。 + * + * @param sql 実行するSQL + * @throws SQLException SQLの実行に失敗した場合 + */ + public void execute(String sql) throws SQLException { + logger.info(sql); + + connection.setAutoCommit(false); + + Statement stmt = null; + ResultSet rs = null; + try { + stmt = connection.createStatement(); + + if (stmt.execute(sql)) { + rs = stmt.getResultSet(); + } + + if (handler != null) { + handler.sqlExecuted(sql, rs); + } + + connection.commit(); + } finally { + JmIOUtil.closeQuietly(rs); + JmIOUtil.closeQuietly(stmt); + } + } + + /** + * SQL実行後に呼び出すハンドラをセットする。 + * + * @param handler ハンドラ + */ + public void setHandler(SqlExecutorHandler handler) { + this.handler = handler; + } + + /** + * 実行するSQLを保持する入力ストリームをセットする。 + * + * @param is 実行するSQLを保持する入力ストリーム + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public void setInputStream(InputStream is) { + Validate.notNull(is); + in = new InputStreamReader(is); + } + + /** + * 実行するSQLを保持する入力ストリームをセットする。 + * + * @param in 実行するSQLを保持する入力ストリーム + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public void setReader(Reader in) { + Validate.notNull(in); + this.in = in; + } + + @Override + protected void finalize() throws Throwable { + IOUtils.closeQuietly(in); + + super.finalize(); + } + + + /** + * SQL実行クラスが、1つのSQLを実行後に呼び出すハンドラインタフェース。 + * + * @author Keisuke.K + */ + public interface SqlExecutorHandler { + + /** + * SQLが実行されると呼び出されるハンドラメソッド。 + * + * @param sql 実行したSQL + * @param rs 実行結果の {@link ResultSet}。SQLの実行結果が {@link ResultSet} とならないSQLの場合、<code>null</code>。 + */ + void sqlExecuted(String sql, ResultSet rs); + + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/SqlExecutor.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/StringUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/StringUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/StringUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,549 +1,549 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/06/09 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.Locale; - -import org.apache.commons.lang.StringUtils; - -import org.jiemamy.exception.JiemamyError; - -/** - * Stringユーティリティ。 - * - * @author j5ik2o - */ -public final class StringUtil { - - private static final int C_8 = 8; - - private static final int C_16 = 16; - - private static final int C_24 = 24; - - private static final int C_0XFF = 0xff; - - private static final int C_0X0F = 0x0f; - - private static final int C_0XF0 = 0xf0; - - private static final int CAMELIZE_BUFF_SIZE = 40; - - private static final int REPLACE_BUFF_SIZE = 100; - - /** 空の文字列の配列。*/ - public static final String[] EMPTY_STRINGS = new String[0]; - - - /** - * 文字列に、数値を16進数に変換した文字列を追加します。 - * - * @param buf 追加先の文字列 - * @param i 数値 - */ - public static void appendHex(final StringBuffer buf, final byte i) { - buf.append(Character.forDigit((i & C_0X0F) >> 4, 16)); - buf.append(Character.forDigit(i & C_0XF0, 16)); - } - - /** - * 文字列に、数値を16進数に変換した文字列を追加します。 - * - * @param buf 追加先の文字列 - * @param i 数値 - */ - public static void appendHex(final StringBuffer buf, final int i) { - buf.append(Integer.toHexString((i >> C_24) & C_0XFF)); - buf.append(Integer.toHexString((i >> C_16) & C_0XFF)); - buf.append(Integer.toHexString((i >> C_8) & C_0XFF)); - buf.append(Integer.toHexString(i & C_0XFF)); - } - - /** - * _記法をキャメル記法に変換します。 - * - * @param s テキスト - * @return 結果の文字列 - */ - public static String camelize(String s) { - String current = s; - if (current == null) { - return null; - } - current = current.toLowerCase(Locale.getDefault()); - String[] array = StringUtils.split(current, "_"); - if (array.length == 1) { - return capitalize(current); - } - StringBuffer buf = new StringBuffer(CAMELIZE_BUFF_SIZE); - for (int i = 0; i < array.length; ++i) { - buf.append(capitalize(array[i])); - } - return buf.toString(); - } - - /** - * JavaBeansの仕様にしたがってキャピタライズを行ないます。 - * 大文字が2つ以上続く場合は、大文字にならないので注意してください。 - * - * @param name 名前 - * @return 結果の文字列 - */ - public static String capitalize(final String name) { - if (isEmpty(name)) { - return name; - } - char[] chars = name.toCharArray(); - chars[0] = Character.toUpperCase(chars[0]); - return new String(chars); - } - - /** - * charを含んでいるかどうか返します。 - * - * @param str 文字列 - * @param ch char - * @return charを含んでいるかどうか - */ - public static boolean contains(final String str, final char ch) { - if (isEmpty(str)) { - return false; - } - return str.indexOf(ch) >= 0; - } - - /** - * 文字列を含んでいるかどうか返します。 - * - * @param s1 文字列 - * @param s2 比較する対象となる文字列 - * @return 文字列を含んでいるかどうか - */ - public static boolean contains(final String s1, final String s2) { - if (isEmpty(s1)) { - return false; - } - return s1.indexOf(s2) >= 0; - } - - /** - * キャメル記法を_記法に変換します。 - * - * @param s テキスト - * @return 結果の文字列 - */ - public static String decamelize(final String s) { - if (s == null) { - return null; - } - if (s.length() == 1) { - return s.toUpperCase(Locale.getDefault()); - } - StringBuffer buf = new StringBuffer(CAMELIZE_BUFF_SIZE); - int pos = 0; - for (int i = 1; i < s.length(); ++i) { - if (Character.isUpperCase(s.charAt(i))) { - if (buf.length() != 0) { - buf.append('_'); - } - buf.append(s.substring(pos, i).toUpperCase(Locale.getDefault())); - pos = i; - } - } - if (buf.length() != 0) { - buf.append('_'); - } - buf.append(s.substring(pos, s.length()).toUpperCase(Locale.getDefault())); - return buf.toString(); - } - - /** - * JavaBeansの仕様にしたがってデキャピタライズを行ないます。大文字が2つ以上続く場合は、小文字にならないので注意してください。 - * - * @param name 名前 - * @return 結果の文字列 - */ - public static String decapitalize(final String name) { - if (isEmpty(name)) { - return name; - } - char[] chars = name.toCharArray(); - if (chars.length >= 2 && Character.isUpperCase(chars[0]) && Character.isUpperCase(chars[1])) { - return name; - } - chars[0] = Character.toLowerCase(chars[0]); - return new String(chars); - } - - /** - * ケースインセンシティブで特定の文字で終わっているのかどうかを返します。 - * - * @param target1 テキスト - * @param target2 比較する文字列 - * @return ケースインセンシティブで特定の文字で終わっているのかどうか - */ - public static boolean endsWithIgnoreCase(final String target1, final String target2) { - if (target1 == null || target2 == null) { - return false; - } - int length1 = target1.length(); - int length2 = target2.length(); - if (length1 < length2) { - return false; - } - String s1 = target1.substring(length1 - length2); - return s1.equalsIgnoreCase(target2); - } - - /** - * 文字列同士が等しいかどうか返します。どちらもnullの場合は、<code>true</code>を返します。 - * - * @param target1 文字列1 - * @param target2 文字列2 - * @return 文字列同士が等しいかどうか - */ - public static boolean equals(final String target1, final String target2) { - return (target1 == null) ? (target2 == null) : target1.equals(target2); - } - - /** - * ケースインセンシティブで文字列同士が等しいかどうか返します。どちらもnullの場合は、<code>true</code>を返します。 - * - * @param target1 文字列1 - * @param target2 文字列2 - * @return ケースインセンシティブで文字列同士が等しいか - */ - public static boolean equalsIgnoreCase(final String target1, final String target2) { - return (target1 == null) ? (target2 == null) : target1.equalsIgnoreCase(target2); - } - - /** - * ブランクかどうか返します。 - * - * @param str 文字列 - * @return ブランクかどうか - */ - public static boolean isBlank(final String str) { - if (str == null || str.length() == 0) { - return true; - } - for (int i = 0; i < str.length(); i++) { - if (!Character.isWhitespace(str.charAt(i))) { - return false; - } - } - return true; - } - - /** - * 文字列が<code>null</code>または空文字列なら<code>true</code>を返します。 - * - * @param text 文字列 - * @return 文字列が<code>null</code>または空文字列なら<code>true</code> - */ - public static boolean isEmpty(final String text) { - return text == null || text.length() == 0; - } - - /** - * ブランクではないかどうか返します。 - * - * @param str 文字列 - * @return ブランクではないかどうか - * @see #isBlank(String) - */ - public static boolean isNotBlank(final String str) { - return !isBlank(str); - } - - /** - * 文字列が<code>null</code>でも空文字列でもなければ<code>true</code>を返します。 - * - * @param text 文字列 - * @return 文字列が<code>null</code>でも空文字列でもなければ<code>true</code> - * @since 2.4.33 - */ - public static boolean isNotEmpty(final String text) { - return !isEmpty(text); - } - - /** - * 文字列が数値のみで構成されているかどうかを返します。 - * - * @param s 文字列 - * @return 数値のみで構成されている場合、<code>true</code> - */ - public static boolean isNumber(final String s) { - if (s == null || s.length() == 0) { - return false; - } - - int size = s.length(); - for (int i = 0; i < size; i++) { - char chr = s.charAt(i); - if (chr < '0' || '9' < chr) { - return false; - } - } - - return true; - } - - /** - * 左側の空白を削ります。 - * - * @param text テキスト - * @return 結果の文字列 - */ - public static String ltrim(final String text) { - return ltrim(text, null); - } - - /** - * 左側の指定した文字列を削ります。 - * - * @param text テキスト - * @param trimText 削るテキスト - * @return 結果の文字列 - */ - public static String ltrim(final String text, String trimText) { - if (text == null) { - return null; - } - if (trimText == null) { - trimText = " "; - } - int pos = 0; - for (; pos < text.length(); pos++) { - if (trimText.indexOf(text.charAt(pos)) < 0) { - break; - } - } - return text.substring(pos); - } - - /** - * 文字列を置き換えます。 - * - * @param text テキスト - * @param fromText 置き換え対象のテキスト - * @param toText 置き換えるテキスト - * @return 結果 - */ - public static String replace(final String text, final String fromText, final String toText) { - if (text == null || fromText == null || toText == null) { - return null; - } - StringBuffer buf = new StringBuffer(REPLACE_BUFF_SIZE); - int pos = 0; - int pos2 = 0; - while (true) { - pos = text.indexOf(fromText, pos2); - if (pos == 0) { - buf.append(toText); - pos2 = fromText.length(); - } else if (pos > 0) { - buf.append(text.substring(pos2, pos)); - buf.append(toText); - pos2 = pos + fromText.length(); - } else { - buf.append(text.substring(pos2)); - break; - } - } - return buf.toString(); - } - - /** - * 右側の空白を削ります。 - * - * @param text テキスト - * @return 結果の文字列 - */ - public static String rtrim(final String text) { - return rtrim(text, null); - } - - /** - * 右側の指定した文字列を削ります。 - * - * @param text テキスト - * @param trimText 削る文字列 - * @return 結果の文字列 - */ - public static String rtrim(final String text, String trimText) { - if (text == null) { - return null; - } - if (trimText == null) { - trimText = " "; - } - int pos = text.length() - 1; - for (; pos >= 0; pos--) { - if (trimText.indexOf(text.charAt(pos)) < 0) { - break; - } - } - return text.substring(0, pos + 1); - } - - /** - * 文字列を分割します。 - * - * @param str 文字列 - * @param delim 分割するためのデリミタ - * @return 分割された文字列の配列 - */ - public static String[] split(final String str, final String delim) { - if (isEmpty(str)) { - return EMPTY_STRINGS; - } - return str.split(delim); - } - - /** - * ケースインセンシティブで特定の文字ではじまっているのかどうかを返します。 - * - * @param target1 テキスト - * @param target2 比較する文字列 - * @return ケースインセンシティブで特定の文字ではじまっているのかどうか - */ - public static boolean startsWithIgnoreCase(final String target1, final String target2) { - if (target1 == null || target2 == null) { - return false; - } - int length1 = target1.length(); - int length2 = target2.length(); - if (length1 < length2) { - return false; - } - String s1 = target1.substring(0, target2.length()); - return s1.equalsIgnoreCase(target2); - } - - /** - * 文字列の最後から指定した文字列で始まっている部分より手前を返します。 - * - * @param str 文字列 - * @param separator セパレータ - * @return 結果の文字列 - */ - public static String substringFromLast(final String str, final String separator) { - if (isEmpty(str) || isEmpty(separator)) { - return str; - } - int pos = str.lastIndexOf(separator); - if (pos == -1) { - return str; - } - return str.substring(0, pos); - } - - /** - * 文字列の最後から指定した文字列で始まっている部分より後ろを返します。 - * - * @param str 文字列 - * @param separator セパレータ - * @return 結果の文字列 - */ - public static String substringToLast(final String str, final String separator) { - if (isEmpty(str) || isEmpty(separator)) { - return str; - } - int pos = str.lastIndexOf(separator); - if (pos == -1) { - return str; - } - return str.substring(pos + 1, str.length()); - } - - /** - * 16進数の文字列に変換します。 - * - * @param bytes バイトの配列 - * @return 16進数の文字列 - */ - public static String toHex(final byte[] bytes) { - if (bytes == null) { - return ""; - } - StringBuffer sb = new StringBuffer(bytes.length * 2); - for (int i = 0; i < bytes.length; ++i) { - appendHex(sb, bytes[i]); - } - return sb.toString(); - } - - /** - * 16進数の文字列に変換します。 - * - * @param i int - * @return 16進数の文字列 - */ - public static String toHex(final int i) { - StringBuffer buf = new StringBuffer(); - appendHex(buf, i); - return buf.toString(); - } - - /** - * プレフィックスを削除する。 - * - * @param text テキスト - * @param prefix プレフィックス - * @return 結果の文字列 - */ - public static String trimPrefix(final String text, final String prefix) { - if (text == null) { - return null; - } - if (prefix == null) { - return text; - } - if (text.startsWith(prefix)) { - return text.substring(prefix.length()); - } - return text; - } - - /** - * サフィックスを削ります。 - * - * @param text テキスト - * @param suffix サフィックス - * @return 結果の文字列 - */ - public static String trimSuffix(final String text, final String suffix) { - if (text == null) { - return null; - } - if (suffix == null) { - return text; - } - if (text.endsWith(suffix)) { - return text.substring(0, text.length() - suffix.length()); - } - return text; - } - - private StringUtil() { - throw new JiemamyError("不到達ポイント"); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/06/09 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.Locale; + +import org.apache.commons.lang.StringUtils; + +import org.jiemamy.exception.JiemamyError; + +/** + * Stringユーティリティ。 + * + * @author j5ik2o + */ +public final class StringUtil { + + private static final int C_8 = 8; + + private static final int C_16 = 16; + + private static final int C_24 = 24; + + private static final int C_0XFF = 0xff; + + private static final int C_0X0F = 0x0f; + + private static final int C_0XF0 = 0xf0; + + private static final int CAMELIZE_BUFF_SIZE = 40; + + private static final int REPLACE_BUFF_SIZE = 100; + + /** 空の文字列の配列。*/ + public static final String[] EMPTY_STRINGS = new String[0]; + + + /** + * 文字列に、数値を16進数に変換した文字列を追加します。 + * + * @param buf 追加先の文字列 + * @param i 数値 + */ + public static void appendHex(final StringBuffer buf, final byte i) { + buf.append(Character.forDigit((i & C_0X0F) >> 4, 16)); + buf.append(Character.forDigit(i & C_0XF0, 16)); + } + + /** + * 文字列に、数値を16進数に変換した文字列を追加します。 + * + * @param buf 追加先の文字列 + * @param i 数値 + */ + public static void appendHex(final StringBuffer buf, final int i) { + buf.append(Integer.toHexString((i >> C_24) & C_0XFF)); + buf.append(Integer.toHexString((i >> C_16) & C_0XFF)); + buf.append(Integer.toHexString((i >> C_8) & C_0XFF)); + buf.append(Integer.toHexString(i & C_0XFF)); + } + + /** + * _記法をキャメル記法に変換します。 + * + * @param s テキスト + * @return 結果の文字列 + */ + public static String camelize(String s) { + String current = s; + if (current == null) { + return null; + } + current = current.toLowerCase(Locale.getDefault()); + String[] array = StringUtils.split(current, "_"); + if (array.length == 1) { + return capitalize(current); + } + StringBuffer buf = new StringBuffer(CAMELIZE_BUFF_SIZE); + for (int i = 0; i < array.length; ++i) { + buf.append(capitalize(array[i])); + } + return buf.toString(); + } + + /** + * JavaBeansの仕様にしたがってキャピタライズを行ないます。 + * 大文字が2つ以上続く場合は、大文字にならないので注意してください。 + * + * @param name 名前 + * @return 結果の文字列 + */ + public static String capitalize(final String name) { + if (isEmpty(name)) { + return name; + } + char[] chars = name.toCharArray(); + chars[0] = Character.toUpperCase(chars[0]); + return new String(chars); + } + + /** + * charを含んでいるかどうか返します。 + * + * @param str 文字列 + * @param ch char + * @return charを含んでいるかどうか + */ + public static boolean contains(final String str, final char ch) { + if (isEmpty(str)) { + return false; + } + return str.indexOf(ch) >= 0; + } + + /** + * 文字列を含んでいるかどうか返します。 + * + * @param s1 文字列 + * @param s2 比較する対象となる文字列 + * @return 文字列を含んでいるかどうか + */ + public static boolean contains(final String s1, final String s2) { + if (isEmpty(s1)) { + return false; + } + return s1.indexOf(s2) >= 0; + } + + /** + * キャメル記法を_記法に変換します。 + * + * @param s テキスト + * @return 結果の文字列 + */ + public static String decamelize(final String s) { + if (s == null) { + return null; + } + if (s.length() == 1) { + return s.toUpperCase(Locale.getDefault()); + } + StringBuffer buf = new StringBuffer(CAMELIZE_BUFF_SIZE); + int pos = 0; + for (int i = 1; i < s.length(); ++i) { + if (Character.isUpperCase(s.charAt(i))) { + if (buf.length() != 0) { + buf.append('_'); + } + buf.append(s.substring(pos, i).toUpperCase(Locale.getDefault())); + pos = i; + } + } + if (buf.length() != 0) { + buf.append('_'); + } + buf.append(s.substring(pos, s.length()).toUpperCase(Locale.getDefault())); + return buf.toString(); + } + + /** + * JavaBeansの仕様にしたがってデキャピタライズを行ないます。大文字が2つ以上続く場合は、小文字にならないので注意してください。 + * + * @param name 名前 + * @return 結果の文字列 + */ + public static String decapitalize(final String name) { + if (isEmpty(name)) { + return name; + } + char[] chars = name.toCharArray(); + if (chars.length >= 2 && Character.isUpperCase(chars[0]) && Character.isUpperCase(chars[1])) { + return name; + } + chars[0] = Character.toLowerCase(chars[0]); + return new String(chars); + } + + /** + * ケースインセンシティブで特定の文字で終わっているのかどうかを返します。 + * + * @param target1 テキスト + * @param target2 比較する文字列 + * @return ケースインセンシティブで特定の文字で終わっているのかどうか + */ + public static boolean endsWithIgnoreCase(final String target1, final String target2) { + if (target1 == null || target2 == null) { + return false; + } + int length1 = target1.length(); + int length2 = target2.length(); + if (length1 < length2) { + return false; + } + String s1 = target1.substring(length1 - length2); + return s1.equalsIgnoreCase(target2); + } + + /** + * 文字列同士が等しいかどうか返します。どちらもnullの場合は、<code>true</code>を返します。 + * + * @param target1 文字列1 + * @param target2 文字列2 + * @return 文字列同士が等しいかどうか + */ + public static boolean equals(final String target1, final String target2) { + return (target1 == null) ? (target2 == null) : target1.equals(target2); + } + + /** + * ケースインセンシティブで文字列同士が等しいかどうか返します。どちらもnullの場合は、<code>true</code>を返します。 + * + * @param target1 文字列1 + * @param target2 文字列2 + * @return ケースインセンシティブで文字列同士が等しいか + */ + public static boolean equalsIgnoreCase(final String target1, final String target2) { + return (target1 == null) ? (target2 == null) : target1.equalsIgnoreCase(target2); + } + + /** + * ブランクかどうか返します。 + * + * @param str 文字列 + * @return ブランクかどうか + */ + public static boolean isBlank(final String str) { + if (str == null || str.length() == 0) { + return true; + } + for (int i = 0; i < str.length(); i++) { + if (!Character.isWhitespace(str.charAt(i))) { + return false; + } + } + return true; + } + + /** + * 文字列が<code>null</code>または空文字列なら<code>true</code>を返します。 + * + * @param text 文字列 + * @return 文字列が<code>null</code>または空文字列なら<code>true</code> + */ + public static boolean isEmpty(final String text) { + return text == null || text.length() == 0; + } + + /** + * ブランクではないかどうか返します。 + * + * @param str 文字列 + * @return ブランクではないかどうか + * @see #isBlank(String) + */ + public static boolean isNotBlank(final String str) { + return !isBlank(str); + } + + /** + * 文字列が<code>null</code>でも空文字列でもなければ<code>true</code>を返します。 + * + * @param text 文字列 + * @return 文字列が<code>null</code>でも空文字列でもなければ<code>true</code> + * @since 2.4.33 + */ + public static boolean isNotEmpty(final String text) { + return !isEmpty(text); + } + + /** + * 文字列が数値のみで構成されているかどうかを返します。 + * + * @param s 文字列 + * @return 数値のみで構成されている場合、<code>true</code> + */ + public static boolean isNumber(final String s) { + if (s == null || s.length() == 0) { + return false; + } + + int size = s.length(); + for (int i = 0; i < size; i++) { + char chr = s.charAt(i); + if (chr < '0' || '9' < chr) { + return false; + } + } + + return true; + } + + /** + * 左側の空白を削ります。 + * + * @param text テキスト + * @return 結果の文字列 + */ + public static String ltrim(final String text) { + return ltrim(text, null); + } + + /** + * 左側の指定した文字列を削ります。 + * + * @param text テキスト + * @param trimText 削るテキスト + * @return 結果の文字列 + */ + public static String ltrim(final String text, String trimText) { + if (text == null) { + return null; + } + if (trimText == null) { + trimText = " "; + } + int pos = 0; + for (; pos < text.length(); pos++) { + if (trimText.indexOf(text.charAt(pos)) < 0) { + break; + } + } + return text.substring(pos); + } + + /** + * 文字列を置き換えます。 + * + * @param text テキスト + * @param fromText 置き換え対象のテキスト + * @param toText 置き換えるテキスト + * @return 結果 + */ + public static String replace(final String text, final String fromText, final String toText) { + if (text == null || fromText == null || toText == null) { + return null; + } + StringBuffer buf = new StringBuffer(REPLACE_BUFF_SIZE); + int pos = 0; + int pos2 = 0; + while (true) { + pos = text.indexOf(fromText, pos2); + if (pos == 0) { + buf.append(toText); + pos2 = fromText.length(); + } else if (pos > 0) { + buf.append(text.substring(pos2, pos)); + buf.append(toText); + pos2 = pos + fromText.length(); + } else { + buf.append(text.substring(pos2)); + break; + } + } + return buf.toString(); + } + + /** + * 右側の空白を削ります。 + * + * @param text テキスト + * @return 結果の文字列 + */ + public static String rtrim(final String text) { + return rtrim(text, null); + } + + /** + * 右側の指定した文字列を削ります。 + * + * @param text テキスト + * @param trimText 削る文字列 + * @return 結果の文字列 + */ + public static String rtrim(final String text, String trimText) { + if (text == null) { + return null; + } + if (trimText == null) { + trimText = " "; + } + int pos = text.length() - 1; + for (; pos >= 0; pos--) { + if (trimText.indexOf(text.charAt(pos)) < 0) { + break; + } + } + return text.substring(0, pos + 1); + } + + /** + * 文字列を分割します。 + * + * @param str 文字列 + * @param delim 分割するためのデリミタ + * @return 分割された文字列の配列 + */ + public static String[] split(final String str, final String delim) { + if (isEmpty(str)) { + return EMPTY_STRINGS; + } + return str.split(delim); + } + + /** + * ケースインセンシティブで特定の文字ではじまっているのかどうかを返します。 + * + * @param target1 テキスト + * @param target2 比較する文字列 + * @return ケースインセンシティブで特定の文字ではじまっているのかどうか + */ + public static boolean startsWithIgnoreCase(final String target1, final String target2) { + if (target1 == null || target2 == null) { + return false; + } + int length1 = target1.length(); + int length2 = target2.length(); + if (length1 < length2) { + return false; + } + String s1 = target1.substring(0, target2.length()); + return s1.equalsIgnoreCase(target2); + } + + /** + * 文字列の最後から指定した文字列で始まっている部分より手前を返します。 + * + * @param str 文字列 + * @param separator セパレータ + * @return 結果の文字列 + */ + public static String substringFromLast(final String str, final String separator) { + if (isEmpty(str) || isEmpty(separator)) { + return str; + } + int pos = str.lastIndexOf(separator); + if (pos == -1) { + return str; + } + return str.substring(0, pos); + } + + /** + * 文字列の最後から指定した文字列で始まっている部分より後ろを返します。 + * + * @param str 文字列 + * @param separator セパレータ + * @return 結果の文字列 + */ + public static String substringToLast(final String str, final String separator) { + if (isEmpty(str) || isEmpty(separator)) { + return str; + } + int pos = str.lastIndexOf(separator); + if (pos == -1) { + return str; + } + return str.substring(pos + 1, str.length()); + } + + /** + * 16進数の文字列に変換します。 + * + * @param bytes バイトの配列 + * @return 16進数の文字列 + */ + public static String toHex(final byte[] bytes) { + if (bytes == null) { + return ""; + } + StringBuffer sb = new StringBuffer(bytes.length * 2); + for (int i = 0; i < bytes.length; ++i) { + appendHex(sb, bytes[i]); + } + return sb.toString(); + } + + /** + * 16進数の文字列に変換します。 + * + * @param i int + * @return 16進数の文字列 + */ + public static String toHex(final int i) { + StringBuffer buf = new StringBuffer(); + appendHex(buf, i); + return buf.toString(); + } + + /** + * プレフィックスを削除する。 + * + * @param text テキスト + * @param prefix プレフィックス + * @return 結果の文字列 + */ + public static String trimPrefix(final String text, final String prefix) { + if (text == null) { + return null; + } + if (prefix == null) { + return text; + } + if (text.startsWith(prefix)) { + return text.substring(prefix.length()); + } + return text; + } + + /** + * サフィックスを削ります。 + * + * @param text テキスト + * @param suffix サフィックス + * @return 結果の文字列 + */ + public static String trimSuffix(final String text, final String suffix) { + if (text == null) { + return null; + } + if (suffix == null) { + return text; + } + if (text.endsWith(suffix)) { + return text.substring(0, text.length() - suffix.length()); + } + return text; + } + + private StringUtil() { + throw new JiemamyError("不到達ポイント"); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/StringUtil.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/TraversalHandlerException.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/TraversalHandlerException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/TraversalHandlerException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,65 +1,65 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 4, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -/** - * ハンドラの処理が失敗した場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class TraversalHandlerException extends Exception { - - /** - * インスタンスを生成する。 - * - */ - public TraversalHandlerException() { - super(); - } - - /** - * インスタンスを生成する。 - * - * @param message メッセージ - */ - public TraversalHandlerException(String message) { - super(message); - } - - /** - * インスタンスを生成する。 - * - * @param message メッセージ - * @param cause 原因 - */ - public TraversalHandlerException(String message, Throwable cause) { - super(message, cause); - } - - /** - * インスタンスを生成する。 - * - * @param cause 原因 - */ - public TraversalHandlerException(Throwable cause) { - super(cause); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 4, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +/** + * ハンドラの処理が失敗した場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class TraversalHandlerException extends Exception { + + /** + * インスタンスを生成する。 + * + */ + public TraversalHandlerException() { + super(); + } + + /** + * インスタンスを生成する。 + * + * @param message メッセージ + */ + public TraversalHandlerException(String message) { + super(message); + } + + /** + * インスタンスを生成する。 + * + * @param message メッセージ + * @param cause 原因 + */ + public TraversalHandlerException(String message, Throwable cause) { + super(message, cause); + } + + /** + * インスタンスを生成する。 + * + * @param cause 原因 + */ + public TraversalHandlerException(Throwable cause) { + super(cause); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/TraversalHandlerException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/URLUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/URLUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/URLUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,159 +1,159 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLDecoder; -import java.net.URLEncoder; -import java.util.HashMap; -import java.util.Map; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link URL}を扱うユーティリティ・クラス。 - * - * @author j5ik2o - */ -public class URLUtil { - - /** プロトコルを正規化するためのマップ */ - protected static final Map<String, String> CANONICAL_PROTOCOLS = new HashMap<String, String>(); - static { - CANONICAL_PROTOCOLS.put("wsjar", "jar"); // WebSphereがJarファイルのために使用する固有のプロトコル - } - - - /** - * <code>String</code>表現から<code>URL</code>オブジェクトを作成します。 - * - * @param spec <code>URL</code>として構文解析される<code>String</code> - * @return <code>URL</code> - * @throws MalformedURLException 無効なURLが発生した場合 - */ - public static URL create(String spec) throws MalformedURLException { - return new URL(spec); - } - - /** - * 指定されたコンテキスト内の指定された仕様で構文解析することによって、<code>URL</code>を生成する。 - * - * @param context 仕様を構文解析するコンテキスト - * @param spec <code>URL</code>として構文解析される<code>String</code> - * @return <code>URL</code> - * @throws MalformedURLException 文字列に指定されたプロトコルが未知である場合 - */ - public static URL create(URL context, String spec) throws MalformedURLException { - return new URL(context, spec); - } - - /** - * 特別な符号化方式を使用して<code>application/x-www-form-urlencoded</code>文字列をデコードする。 - * - * @param s デコード対象の<code>String</code> - * @param enc サポートされる文字エンコーディングの名前 - * @return 新しくデコードされた String - * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされていない場合 - */ - public static String decode(final String s, final String enc) throws UnsupportedEncodingException { - return URLDecoder.decode(s, enc); - } - - /** - * <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4167874">このバグ</a>に対する対応です。 - * - */ -// public static void disableURLCaches() { -// BeanDesc bd = BeanDescFactory.getBeanDesc(URLConnection.class); -// FieldUtil.set(bd.getField("defaultUseCaches"), null, Boolean.FALSE); -// } - /** - * 特定の符号化方式を使用して文字列を<code>application/x-www-form-urlencoded</code>形式に変換する。 - * - * @param s 変換対象の String - * @param enc サポートされる文字エンコーディングの名前 - * @return 変換後の<code>String</code> - * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされてない場合 - */ - public static String encode(final String s, final String enc) throws UnsupportedEncodingException { - return URLEncoder.encode(s, enc); - } - - /** - * URLが参照するリモートオブジェクトへの接続を表す{@link URLConnection}オブジェクトを取得する。 - * - * @param url URL - * @return URLへの{@link URLConnection}オブジェクト - * @throws IOException 入出力が失敗した場合 - */ - public static URLConnection openConnection(URL url) throws IOException { - URLConnection connection = url.openConnection(); - connection.setUseCaches(false); - return connection; - } - - /** - * URLをオープンして{@link InputStream}を取得する。 - * - * @param url URL - * @return URLが表すリソースを読み込むための{@link InputStream} - * @throws IOException 入出力が失敗した場合 - */ - public static InputStream openStream(URL url) throws IOException { - URLConnection connection = url.openConnection(); - connection.setUseCaches(false); - return connection.getInputStream(); - } - - /** - * 正規化されたプロトコルを取得する。 - * - * @param protocol プロトコル - * @return 正規化されたプロトコル - */ - public static String toCanonicalProtocol(final String protocol) { - final String canonicalProtocol = CANONICAL_PROTOCOLS.get(protocol); - if (canonicalProtocol != null) { - return canonicalProtocol; - } - return protocol; - } - - /** - * URLが示すJarファイルの{@link File}オブジェクトを取得する。 - * - * @param fileUrl JarファイルのURL - * @return Jarファイルの{@link File} - * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされてない場合 - */ - public static File toFile(final URL fileUrl) throws UnsupportedEncodingException { - final String path = URLDecoder.decode(fileUrl.getPath(), "UTF-8"); - return new File(path).getAbsoluteFile(); - } - - private URLUtil() { - throw new JiemamyError("不到達ポイント"); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.Map; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link URL}を扱うユーティリティ・クラス。 + * + * @author j5ik2o + */ +public class URLUtil { + + /** プロトコルを正規化するためのマップ */ + protected static final Map<String, String> CANONICAL_PROTOCOLS = new HashMap<String, String>(); + static { + CANONICAL_PROTOCOLS.put("wsjar", "jar"); // WebSphereがJarファイルのために使用する固有のプロトコル + } + + + /** + * <code>String</code>表現から<code>URL</code>オブジェクトを作成します。 + * + * @param spec <code>URL</code>として構文解析される<code>String</code> + * @return <code>URL</code> + * @throws MalformedURLException 無効なURLが発生した場合 + */ + public static URL create(String spec) throws MalformedURLException { + return new URL(spec); + } + + /** + * 指定されたコンテキスト内の指定された仕様で構文解析することによって、<code>URL</code>を生成する。 + * + * @param context 仕様を構文解析するコンテキスト + * @param spec <code>URL</code>として構文解析される<code>String</code> + * @return <code>URL</code> + * @throws MalformedURLException 文字列に指定されたプロトコルが未知である場合 + */ + public static URL create(URL context, String spec) throws MalformedURLException { + return new URL(context, spec); + } + + /** + * 特別な符号化方式を使用して<code>application/x-www-form-urlencoded</code>文字列をデコードする。 + * + * @param s デコード対象の<code>String</code> + * @param enc サポートされる文字エンコーディングの名前 + * @return 新しくデコードされた String + * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされていない場合 + */ + public static String decode(final String s, final String enc) throws UnsupportedEncodingException { + return URLDecoder.decode(s, enc); + } + + /** + * <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4167874">このバグ</a>に対する対応です。 + * + */ +// public static void disableURLCaches() { +// BeanDesc bd = BeanDescFactory.getBeanDesc(URLConnection.class); +// FieldUtil.set(bd.getField("defaultUseCaches"), null, Boolean.FALSE); +// } + /** + * 特定の符号化方式を使用して文字列を<code>application/x-www-form-urlencoded</code>形式に変換する。 + * + * @param s 変換対象の String + * @param enc サポートされる文字エンコーディングの名前 + * @return 変換後の<code>String</code> + * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされてない場合 + */ + public static String encode(final String s, final String enc) throws UnsupportedEncodingException { + return URLEncoder.encode(s, enc); + } + + /** + * URLが参照するリモートオブジェクトへの接続を表す{@link URLConnection}オブジェクトを取得する。 + * + * @param url URL + * @return URLへの{@link URLConnection}オブジェクト + * @throws IOException 入出力が失敗した場合 + */ + public static URLConnection openConnection(URL url) throws IOException { + URLConnection connection = url.openConnection(); + connection.setUseCaches(false); + return connection; + } + + /** + * URLをオープンして{@link InputStream}を取得する。 + * + * @param url URL + * @return URLが表すリソースを読み込むための{@link InputStream} + * @throws IOException 入出力が失敗した場合 + */ + public static InputStream openStream(URL url) throws IOException { + URLConnection connection = url.openConnection(); + connection.setUseCaches(false); + return connection.getInputStream(); + } + + /** + * 正規化されたプロトコルを取得する。 + * + * @param protocol プロトコル + * @return 正規化されたプロトコル + */ + public static String toCanonicalProtocol(final String protocol) { + final String canonicalProtocol = CANONICAL_PROTOCOLS.get(protocol); + if (canonicalProtocol != null) { + return canonicalProtocol; + } + return protocol; + } + + /** + * URLが示すJarファイルの{@link File}オブジェクトを取得する。 + * + * @param fileUrl JarファイルのURL + * @return Jarファイルの{@link File} + * @throws UnsupportedEncodingException 文字のエンコーディングがサポートされてない場合 + */ + public static File toFile(final URL fileUrl) throws UnsupportedEncodingException { + final String path = URLDecoder.decode(fileUrl.getPath(), "UTF-8"); + return new File(path).getAbsoluteFile(); + } + + private URLUtil() { + throw new JiemamyError("不到達ポイント"); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/URLUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/UUIDUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/UUIDUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/UUIDUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,85 +1,85 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/16 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.util.Map; -import java.util.UUID; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * {@link UUID}用ユーティリティクラス。 - * - * @author daisuke - */ -public final class UUIDUtil { - - static Map<String, UUID> cache = CollectionsUtil.newHashMap(); - - private static Logger logger = LoggerFactory.getLogger(UUIDUtil.class); - - -// /** -// * テスト用に使用するUUIDをランダムで発行するための便利メソッド。 -// * -// * @param args 引数. 意味無し -// */ -// public static void main(String[] args) { -// for (int i = 0; i < 5; i++) { -// System.out.println(UUID.randomUUID()); -// } -// } - - /** - * 文字列からUUIDを生成する。 - * - * <p>与えられた文字列表現がUUIDとして不適切であり、生成に失敗した場合は、ランダム生成を行う。</p> - * - * <p>不適切な文字列表現からUUIDを新規生成した場合は、nameとUUIDのマッピングをキャッシュし、 - * 後に同じnameによるUUID取得が行われた場合は、前回と同じUUIDを返す。</p> - * - * @param name UUIDの文字列表現 - * @return 生成したUUID - */ - public static UUID valueOfOrRandom(String name) { - UUID result; - if (name == null) { - result = getUUID(null); - } else { - try { - result = UUID.fromString(name); - } catch (IllegalArgumentException e) { - logger.warn("Illegal UUID: " + name); - result = getUUID(name); - } - } - return result; - } - - private static UUID getUUID(String name) { - if (cache.get(name) == null) { - cache.put(name, UUID.randomUUID()); - } - return cache.get(name); - } - - private UUIDUtil() { - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/16 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.util.Map; +import java.util.UUID; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * {@link UUID}用ユーティリティクラス。 + * + * @author daisuke + */ +public final class UUIDUtil { + + static Map<String, UUID> cache = CollectionsUtil.newHashMap(); + + private static Logger logger = LoggerFactory.getLogger(UUIDUtil.class); + + +// /** +// * テスト用に使用するUUIDをランダムで発行するための便利メソッド。 +// * +// * @param args 引数. 意味無し +// */ +// public static void main(String[] args) { +// for (int i = 0; i < 5; i++) { +// System.out.println(UUID.randomUUID()); +// } +// } + + /** + * 文字列からUUIDを生成する。 + * + * <p>与えられた文字列表現がUUIDとして不適切であり、生成に失敗した場合は、ランダム生成を行う。</p> + * + * <p>不適切な文字列表現からUUIDを新規生成した場合は、nameとUUIDのマッピングをキャッシュし、 + * 後に同じnameによるUUID取得が行われた場合は、前回と同じUUIDを返す。</p> + * + * @param name UUIDの文字列表現 + * @return 生成したUUID + */ + public static UUID valueOfOrRandom(String name) { + UUID result; + if (name == null) { + result = getUUID(null); + } else { + try { + result = UUID.fromString(name); + } catch (IllegalArgumentException e) { + logger.warn("Illegal UUID: " + name); + result = getUUID(name); + } + } + return result; + } + + private static UUID getUUID(String name) { + if (cache.get(name) == null) { + cache.put(name, UUID.randomUUID()); + } + return cache.get(name); + } + + private UUIDUtil() { + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/UUIDUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ValidateUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ValidateUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ValidateUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,44 +1,44 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/21 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -/** - * バリデーションを行うユーティリティクラス。 - * - * @author daisuke - */ -public final class ValidateUtil { - - /** - * インジェクション用のsetterのバリデーションメソッド。 - * - * <p>既に初期化されているフィールドを上書き初期化しようとした際に、例外を投げる。</p> - * - * @param targetField 対象フィールドの値 - * @throws IllegalStateException フィールドが初期化済みであった場合 - */ - public static void injectionSetter(Object targetField) { - if (targetField != null) { - throw new IllegalStateException("duplicate initialize"); - } - } - - private ValidateUtil() { - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/21 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +/** + * バリデーションを行うユーティリティクラス。 + * + * @author daisuke + */ +public final class ValidateUtil { + + /** + * インジェクション用のsetterのバリデーションメソッド。 + * + * <p>既に初期化されているフィールドを上書き初期化しようとした際に、例外を投げる。</p> + * + * @param targetField 対象フィールドの値 + * @throws IllegalStateException フィールドが初期化済みであった場合 + */ + public static void injectionSetter(Object targetField) { + if (targetField != null) { + throw new IllegalStateException("duplicate initialize"); + } + } + + private ValidateUtil() { + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ValidateUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ZipFileUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ZipFileUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ZipFileUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,111 +1,111 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link java.util.zip.ZipFile}を扱うユーティリティクラス。 - * - * @author j5ik2o - */ -public class ZipFileUtil { - - /** - * Zipファイルをクローズする。 - * - * @param zipFile Zipファイル - * @throws IOException 入出力が失敗した場合 - */ - public static void close(final ZipFile zipFile) throws IOException { - zipFile.close(); - - } - - /** - * 指定されたZipファイルを読み取るための<code>ZipFile</code>を取得する。 - * - * @param file ファイル - * @return 指定されたZipファイルを読み取るための<code>ZipFile</code> - * @throws IOException 入出力が失敗した場合 - */ - public static ZipFile create(final File file) throws IOException { - return new ZipFile(file); - } - - /** - * 指定されたZipファイルを読み取るための<code>ZipFile</code>を取得する。 - * - * @param file ファイルパス - * @return 指定されたZipファイルを読み取るための<code>ZipFile</code> - * @throws IOException 入出力が失敗した場合 - */ - public static ZipFile create(final String file) throws IOException { - return new ZipFile(file); - } - - /** - * 指定されたZipファイルエントリの内容を読み込むための入力ストリームを取得する。 - * - * @param file Zipファイル - * @param entry Zipファイルエントリ - * @return 指定されたZipファイルエントリの内容を読み込むための入力ストリーム - * @throws IOException 入出力が失敗した場合 - */ - public static InputStream getInputStream(final ZipFile file, final ZipEntry entry) throws IOException { - return file.getInputStream(entry); - } - - /** - * URLで指定されたZipファイルを読み取るための<code>ZipFile</code>を取得する。 - * - * @param zipUrl Zipファイルを示すURL - * @return 指定されたZipファイルを読み取るための<code>ZipFile</code> - * @throws IOException 入出力が失敗した場合 - */ - public static ZipFile toZipFile(final URL zipUrl) throws IOException { - return create(new File(toZipFilePath(zipUrl))); - } - - /** - * URLで指定されたZipファイルのパスを取得する。 - * - * @param zipUrl Zipファイルを示すURL - * @return URLで指定されたZipファイルのパス - * @throws IOException 入出力が失敗した場合 - */ - public static String toZipFilePath(final URL zipUrl) throws IOException { - final String urlString = zipUrl.getPath(); - final int pos = urlString.lastIndexOf('!'); - final String zipFilePath = urlString.substring(0, pos); - final File zipFile = new File(URLUtil.decode(zipFilePath, "UTF8")); - return FileUtil.getCanonicalPath(zipFile); - } - - private ZipFileUtil() { - throw new JiemamyError("不到達ポイント"); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link java.util.zip.ZipFile}を扱うユーティリティクラス。 + * + * @author j5ik2o + */ +public class ZipFileUtil { + + /** + * Zipファイルをクローズする。 + * + * @param zipFile Zipファイル + * @throws IOException 入出力が失敗した場合 + */ + public static void close(final ZipFile zipFile) throws IOException { + zipFile.close(); + + } + + /** + * 指定されたZipファイルを読み取るための<code>ZipFile</code>を取得する。 + * + * @param file ファイル + * @return 指定されたZipファイルを読み取るための<code>ZipFile</code> + * @throws IOException 入出力が失敗した場合 + */ + public static ZipFile create(final File file) throws IOException { + return new ZipFile(file); + } + + /** + * 指定されたZipファイルを読み取るための<code>ZipFile</code>を取得する。 + * + * @param file ファイルパス + * @return 指定されたZipファイルを読み取るための<code>ZipFile</code> + * @throws IOException 入出力が失敗した場合 + */ + public static ZipFile create(final String file) throws IOException { + return new ZipFile(file); + } + + /** + * 指定されたZipファイルエントリの内容を読み込むための入力ストリームを取得する。 + * + * @param file Zipファイル + * @param entry Zipファイルエントリ + * @return 指定されたZipファイルエントリの内容を読み込むための入力ストリーム + * @throws IOException 入出力が失敗した場合 + */ + public static InputStream getInputStream(final ZipFile file, final ZipEntry entry) throws IOException { + return file.getInputStream(entry); + } + + /** + * URLで指定されたZipファイルを読み取るための<code>ZipFile</code>を取得する。 + * + * @param zipUrl Zipファイルを示すURL + * @return 指定されたZipファイルを読み取るための<code>ZipFile</code> + * @throws IOException 入出力が失敗した場合 + */ + public static ZipFile toZipFile(final URL zipUrl) throws IOException { + return create(new File(toZipFilePath(zipUrl))); + } + + /** + * URLで指定されたZipファイルのパスを取得する。 + * + * @param zipUrl Zipファイルを示すURL + * @return URLで指定されたZipファイルのパス + * @throws IOException 入出力が失敗した場合 + */ + public static String toZipFilePath(final URL zipUrl) throws IOException { + final String urlString = zipUrl.getPath(); + final int pos = urlString.lastIndexOf('!'); + final String zipFilePath = urlString.substring(0, pos); + final File zipFile = new File(URLUtil.decode(zipFilePath, "UTF8")); + return FileUtil.getCanonicalPath(zipFile); + } + + private ZipFileUtil() { + throw new JiemamyError("不到達ポイント"); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ZipFileUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/AttributesMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/AttributesMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/AttributesMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,213 +1,213 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getAttributes(String, String, String, String)}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class AttributesMeta { - - /** type catalog (may be null) */ - public final String typeCat; - - /** type schema (may be null) */ - public final String typeSchem; - - /** type name */ - public final String typeName; - - /** attribute name */ - public final String attrName; - - /** attribute type SQL type from java.sql.Types */ - public final int dataType; - - /** - * Data source dependent type name. For a UDT, the type name is fully qualified. - * For a REF, the type name is fully qualified and represents the target type of the reference type. - */ - public final String attrTypeName; - - /** - * column size. For char or date types this is the maximum number of characters; - * for numeric or decimal types this is precision. - */ - public final int attrSize; - - /** the number of fractional digits */ - public final int decimalDigits; - - /** Radix (typically either 10 or 2) */ - public final int numPrecRadix; - - /** whether NULL is allowed */ - public final Nullable nullable; - - /** comment describing column (may be null) */ - public final String remarks; - - /** default value (may be null) */ - public final String attrDef; - - /** unused */ - public final int sqlDataType; - - /** unused */ - public final int sqlDatetimeSub; - - /** for char types the maximum number of bytes in the column */ - public final int charOctetLength; - - /** index of column in table (starting at 1) */ - public final int ordinalPosition; - - /** - * "NO" means column definitely does not allow NULL values; "YES" means the column might allow NULL values. - * An empty string means unknown. - */ - public final String isNullable; - - /** catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF) */ - public final String scopeCatalog; - - /** schema of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF) */ - public final String scopeSchema; - - /** table name that is the scope of a reference attribute (null if the DATA_TYPE isn't REF)*/ - public final String scopeTable; - - /** - * source type of a distinct type or user-generated Ref type,SQL type from java.sql.Types - * (null if DATA_TYPE isn't DISTINCT or user-generated REF) - */ - public final short sourceDataType; - - - /** - * インスタンスを生成する。 - * - * @param attribute {@link DatabaseMetaData#getAttributes(String, String, String, String)}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public AttributesMeta(ResultSet attribute) { - Validate.notNull(attribute); - typeCat = ResultSetUtil.getString(attribute, "TYPE_CAT"); - typeSchem = ResultSetUtil.getString(attribute, "TYPE_SCHEM"); - typeName = ResultSetUtil.getString(attribute, "TYPE_NAME"); - attrName = ResultSetUtil.getString(attribute, "ATTR_NAME"); - dataType = ResultSetUtil.getInt(attribute, "DATA_TYPE"); - attrTypeName = ResultSetUtil.getString(attribute, "ATTR_TYPE_NAME"); - attrSize = ResultSetUtil.getInt(attribute, "ATTR_SIZE"); - decimalDigits = ResultSetUtil.getInt(attribute, "DECIMAL_DIGITS"); - numPrecRadix = ResultSetUtil.getInt(attribute, "NUM_PREC_RADIX"); - nullable = Nullable.getNullable(ResultSetUtil.getInt(attribute, "NULLABLE")); - remarks = ResultSetUtil.getString(attribute, "REMARKS"); - attrDef = ResultSetUtil.getString(attribute, "ATTR_DEF"); - sqlDataType = ResultSetUtil.getInt(attribute, "SQL_DATA_TYPE"); - sqlDatetimeSub = ResultSetUtil.getInt(attribute, "SQL_DATETIME_SUB"); - charOctetLength = ResultSetUtil.getInt(attribute, "CHAR_OCTET_LENGTH"); - ordinalPosition = ResultSetUtil.getInt(attribute, "ORDINAL_POSITION"); - isNullable = ResultSetUtil.getString(attribute, "IS_NULLABLE"); - scopeCatalog = ResultSetUtil.getString(attribute, "SCOPE_CATALOG"); - scopeSchema = ResultSetUtil.getString(attribute, "SCOPE_SCHEMA"); - scopeTable = ResultSetUtil.getString(attribute, "SCOPE_TABLE"); - sourceDataType = ResultSetUtil.getShort(attribute, "SOURCE_DATA_TYPE"); - - assert typeName != null; - assert attrName != null; - assert attrTypeName != null; - assert nullable != null; - assert isNullable != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - - /** - * NULL は許されるかを表す列挙型。 - * @author daisuke - */ - public static enum Nullable { - - /** might not allow NULL values */ - NO_NULLS(DatabaseMetaData.attributeNoNulls), - - /** definitely allows NULL values */ - NULLABLE(DatabaseMetaData.attributeNullable), - - /** nullability unknown */ - UNKNOWN(DatabaseMetaData.attributeNullableUnknown); - - private static Nullable getNullable(int value) { - return ValueToEnum.get(value); - } - - - private final int value; - - - Nullable(int value) { - this.value = value; - } - - - /** - * 逆参照表を遅延初期化するクラス - * @author daisuke - */ - private static class ValueToEnum { - - private static final Map<Integer, Nullable> REVERSE_DICTIONARY; - static { - Map<Integer, Nullable> map = new HashMap<Integer, Nullable>(); - for (Nullable elem : Nullable.values()) { - map.put(elem.value, elem); - } - REVERSE_DICTIONARY = Collections.unmodifiableMap(map); - } - - - static Nullable get(int key) { - return REVERSE_DICTIONARY.get(key); - } - - private ValueToEnum() { - } - } - - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getAttributes(String, String, String, String)}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class AttributesMeta { + + /** type catalog (may be null) */ + public final String typeCat; + + /** type schema (may be null) */ + public final String typeSchem; + + /** type name */ + public final String typeName; + + /** attribute name */ + public final String attrName; + + /** attribute type SQL type from java.sql.Types */ + public final int dataType; + + /** + * Data source dependent type name. For a UDT, the type name is fully qualified. + * For a REF, the type name is fully qualified and represents the target type of the reference type. + */ + public final String attrTypeName; + + /** + * column size. For char or date types this is the maximum number of characters; + * for numeric or decimal types this is precision. + */ + public final int attrSize; + + /** the number of fractional digits */ + public final int decimalDigits; + + /** Radix (typically either 10 or 2) */ + public final int numPrecRadix; + + /** whether NULL is allowed */ + public final Nullable nullable; + + /** comment describing column (may be null) */ + public final String remarks; + + /** default value (may be null) */ + public final String attrDef; + + /** unused */ + public final int sqlDataType; + + /** unused */ + public final int sqlDatetimeSub; + + /** for char types the maximum number of bytes in the column */ + public final int charOctetLength; + + /** index of column in table (starting at 1) */ + public final int ordinalPosition; + + /** + * "NO" means column definitely does not allow NULL values; "YES" means the column might allow NULL values. + * An empty string means unknown. + */ + public final String isNullable; + + /** catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF) */ + public final String scopeCatalog; + + /** schema of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF) */ + public final String scopeSchema; + + /** table name that is the scope of a reference attribute (null if the DATA_TYPE isn't REF)*/ + public final String scopeTable; + + /** + * source type of a distinct type or user-generated Ref type,SQL type from java.sql.Types + * (null if DATA_TYPE isn't DISTINCT or user-generated REF) + */ + public final short sourceDataType; + + + /** + * インスタンスを生成する。 + * + * @param attribute {@link DatabaseMetaData#getAttributes(String, String, String, String)}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public AttributesMeta(ResultSet attribute) { + Validate.notNull(attribute); + typeCat = ResultSetUtil.getString(attribute, "TYPE_CAT"); + typeSchem = ResultSetUtil.getString(attribute, "TYPE_SCHEM"); + typeName = ResultSetUtil.getString(attribute, "TYPE_NAME"); + attrName = ResultSetUtil.getString(attribute, "ATTR_NAME"); + dataType = ResultSetUtil.getInt(attribute, "DATA_TYPE"); + attrTypeName = ResultSetUtil.getString(attribute, "ATTR_TYPE_NAME"); + attrSize = ResultSetUtil.getInt(attribute, "ATTR_SIZE"); + decimalDigits = ResultSetUtil.getInt(attribute, "DECIMAL_DIGITS"); + numPrecRadix = ResultSetUtil.getInt(attribute, "NUM_PREC_RADIX"); + nullable = Nullable.getNullable(ResultSetUtil.getInt(attribute, "NULLABLE")); + remarks = ResultSetUtil.getString(attribute, "REMARKS"); + attrDef = ResultSetUtil.getString(attribute, "ATTR_DEF"); + sqlDataType = ResultSetUtil.getInt(attribute, "SQL_DATA_TYPE"); + sqlDatetimeSub = ResultSetUtil.getInt(attribute, "SQL_DATETIME_SUB"); + charOctetLength = ResultSetUtil.getInt(attribute, "CHAR_OCTET_LENGTH"); + ordinalPosition = ResultSetUtil.getInt(attribute, "ORDINAL_POSITION"); + isNullable = ResultSetUtil.getString(attribute, "IS_NULLABLE"); + scopeCatalog = ResultSetUtil.getString(attribute, "SCOPE_CATALOG"); + scopeSchema = ResultSetUtil.getString(attribute, "SCOPE_SCHEMA"); + scopeTable = ResultSetUtil.getString(attribute, "SCOPE_TABLE"); + sourceDataType = ResultSetUtil.getShort(attribute, "SOURCE_DATA_TYPE"); + + assert typeName != null; + assert attrName != null; + assert attrTypeName != null; + assert nullable != null; + assert isNullable != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + + + /** + * NULL は許されるかを表す列挙型。 + * @author daisuke + */ + public static enum Nullable { + + /** might not allow NULL values */ + NO_NULLS(DatabaseMetaData.attributeNoNulls), + + /** definitely allows NULL values */ + NULLABLE(DatabaseMetaData.attributeNullable), + + /** nullability unknown */ + UNKNOWN(DatabaseMetaData.attributeNullableUnknown); + + private static Nullable getNullable(int value) { + return ValueToEnum.get(value); + } + + + private final int value; + + + Nullable(int value) { + this.value = value; + } + + + /** + * 逆参照表を遅延初期化するクラス + * @author daisuke + */ + private static class ValueToEnum { + + private static final Map<Integer, Nullable> REVERSE_DICTIONARY; + static { + Map<Integer, Nullable> map = new HashMap<Integer, Nullable>(); + for (Nullable elem : Nullable.values()) { + map.put(elem.value, elem); + } + REVERSE_DICTIONARY = Collections.unmodifiableMap(map); + } + + + static Nullable get(int key) { + return REVERSE_DICTIONARY.get(key); + } + + private ValueToEnum() { + } + } + + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/AttributesMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/BestRowIdentifierMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/BestRowIdentifierMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/BestRowIdentifierMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,160 +1,160 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * 行を一意に識別するテーブルの最適な列セットに関する記述。 - * - * <p>{@link DatabaseMetaData#getBestRowIdentifier(String, String, String, int, boolean)}の結果の一つを表す値クラス。</p> - * - * @author daisuke - */ -public class BestRowIdentifierMeta { - - /** actual scope of result */ - public final Scope scope; - - /** column name */ - public final String columnName; - - /** SQL data type from java.sql.Types */ - public final int dataType; - - /** Data source dependent type name, for a UDT the type name is fully qualified */ - public final String typeName; - - /** precision */ - public final int columnSize; - - /** not used */ - public final int bufferLength; - - /** scale */ - public final short decimalDigits; - - /** is this a pseudo column like an Oracle ROWID */ - public final PseudoColumn pseudoColumn; - - - /** - * インスタンスを生成する。 - * - * @param bestRowIdentifier {@link DatabaseMetaData#getBestRowIdentifier(String, String, String, int, boolean)}の - * 結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public BestRowIdentifierMeta(ResultSet bestRowIdentifier) { - Validate.notNull(bestRowIdentifier); - scope = Scope.getScope(ResultSetUtil.getShort(bestRowIdentifier, "SCOPE")); - columnName = ResultSetUtil.getString(bestRowIdentifier, "COLUMN_NAME"); - dataType = ResultSetUtil.getInt(bestRowIdentifier, "DATA_TYPE"); - typeName = ResultSetUtil.getString(bestRowIdentifier, "TYPE_NAME"); - columnSize = ResultSetUtil.getInt(bestRowIdentifier, "COLUMN_SIZE"); - bufferLength = ResultSetUtil.getInt(bestRowIdentifier, "BUFFER_LENGTH"); - decimalDigits = ResultSetUtil.getShort(bestRowIdentifier, "DECIMAL_DIGITS"); - pseudoColumn = PseudoColumn.getPseudoColumn(ResultSetUtil.getShort(bestRowIdentifier, "PSEUDO_COLUMN")); - - assert scope != null; - assert columnName != null; - assert typeName != null; - assert pseudoColumn != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - - /** - * 疑似列であるかどうかを示す列挙型。 - * @author daisuke - */ - public static enum PseudoColumn { - - /** may or may not be pseudo column */ - UNKNOWN(DatabaseMetaData.bestRowUnknown), - - /** is NOT a pseudo column */ - NOT_PSEUDO(DatabaseMetaData.bestRowNotPseudo), - - /** is a pseudo column */ - PSEUDO(DatabaseMetaData.bestRowPseudo); - - private static PseudoColumn getPseudoColumn(short value) { - for (PseudoColumn pseudoColumn : PseudoColumn.values()) { - if (pseudoColumn.value == value) { - return pseudoColumn; - } - } - return null; - } - - - private int value; - - - PseudoColumn(int value) { - this.value = value; - } - } - - /** - * 結果の実際のスケール?(何のこっちゃ) - * @author daisuke - */ - public static enum Scope { - - /** very temporary, while using row */ - TEMPORARY(DatabaseMetaData.bestRowTemporary), - - /** valid for remainder of current transaction */ - TRANSACTION(DatabaseMetaData.bestRowTransaction), - - /** valid for remainder of current session */ - SESSION(DatabaseMetaData.bestRowSession); - - private static Scope getScope(short value) { - for (Scope scope : Scope.values()) { - if (scope.value == value) { - return scope; - } - } - return null; - } - - - private int value; - - - Scope(int value) { - this.value = value; - } - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * 行を一意に識別するテーブルの最適な列セットに関する記述。 + * + * <p>{@link DatabaseMetaData#getBestRowIdentifier(String, String, String, int, boolean)}の結果の一つを表す値クラス。</p> + * + * @author daisuke + */ +public class BestRowIdentifierMeta { + + /** actual scope of result */ + public final Scope scope; + + /** column name */ + public final String columnName; + + /** SQL data type from java.sql.Types */ + public final int dataType; + + /** Data source dependent type name, for a UDT the type name is fully qualified */ + public final String typeName; + + /** precision */ + public final int columnSize; + + /** not used */ + public final int bufferLength; + + /** scale */ + public final short decimalDigits; + + /** is this a pseudo column like an Oracle ROWID */ + public final PseudoColumn pseudoColumn; + + + /** + * インスタンスを生成する。 + * + * @param bestRowIdentifier {@link DatabaseMetaData#getBestRowIdentifier(String, String, String, int, boolean)}の + * 結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public BestRowIdentifierMeta(ResultSet bestRowIdentifier) { + Validate.notNull(bestRowIdentifier); + scope = Scope.getScope(ResultSetUtil.getShort(bestRowIdentifier, "SCOPE")); + columnName = ResultSetUtil.getString(bestRowIdentifier, "COLUMN_NAME"); + dataType = ResultSetUtil.getInt(bestRowIdentifier, "DATA_TYPE"); + typeName = ResultSetUtil.getString(bestRowIdentifier, "TYPE_NAME"); + columnSize = ResultSetUtil.getInt(bestRowIdentifier, "COLUMN_SIZE"); + bufferLength = ResultSetUtil.getInt(bestRowIdentifier, "BUFFER_LENGTH"); + decimalDigits = ResultSetUtil.getShort(bestRowIdentifier, "DECIMAL_DIGITS"); + pseudoColumn = PseudoColumn.getPseudoColumn(ResultSetUtil.getShort(bestRowIdentifier, "PSEUDO_COLUMN")); + + assert scope != null; + assert columnName != null; + assert typeName != null; + assert pseudoColumn != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + + + /** + * 疑似列であるかどうかを示す列挙型。 + * @author daisuke + */ + public static enum PseudoColumn { + + /** may or may not be pseudo column */ + UNKNOWN(DatabaseMetaData.bestRowUnknown), + + /** is NOT a pseudo column */ + NOT_PSEUDO(DatabaseMetaData.bestRowNotPseudo), + + /** is a pseudo column */ + PSEUDO(DatabaseMetaData.bestRowPseudo); + + private static PseudoColumn getPseudoColumn(short value) { + for (PseudoColumn pseudoColumn : PseudoColumn.values()) { + if (pseudoColumn.value == value) { + return pseudoColumn; + } + } + return null; + } + + + private int value; + + + PseudoColumn(int value) { + this.value = value; + } + } + + /** + * 結果の実際のスケール?(何のこっちゃ) + * @author daisuke + */ + public static enum Scope { + + /** very temporary, while using row */ + TEMPORARY(DatabaseMetaData.bestRowTemporary), + + /** valid for remainder of current transaction */ + TRANSACTION(DatabaseMetaData.bestRowTransaction), + + /** valid for remainder of current session */ + SESSION(DatabaseMetaData.bestRowSession); + + private static Scope getScope(short value) { + for (Scope scope : Scope.values()) { + if (scope.value == value) { + return scope; + } + } + return null; + } + + + private int value; + + + Scope(int value) { + this.value = value; + } + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/BestRowIdentifierMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/CatalogMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/CatalogMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/CatalogMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,59 +1,59 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getCatalogs()}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class CatalogMeta { - - /** catalog name */ - public final String tableCat; - - - /** - * インスタンスを生成する。 - * - * @param catalogs {@link DatabaseMetaData#getCatalogs()}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public CatalogMeta(ResultSet catalogs) { - Validate.notNull(catalogs); - tableCat = ResultSetUtil.getString(catalogs, "TABLE_CAT"); - - assert tableCat != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getCatalogs()}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class CatalogMeta { + + /** catalog name */ + public final String tableCat; + + + /** + * インスタンスを生成する。 + * + * @param catalogs {@link DatabaseMetaData#getCatalogs()}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public CatalogMeta(ResultSet catalogs) { + Validate.notNull(catalogs); + tableCat = ResultSetUtil.getString(catalogs, "TABLE_CAT"); + + assert tableCat != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/CatalogMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ColumnMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ColumnMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ColumnMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,199 +1,199 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/25 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * DBから読み出したカラム情報の保持クラス。 - * - * <p>{@link DatabaseMetaData#getTables(String, String, String, String[])}の結果の一つを表す値クラス。</p> - * - * @author daisuke - */ -public class ColumnMeta { - - /** unused */ - public final int sqlDataType; - - /** unused */ - public final int sqlDatetimeSub; - - /** table catalog (may be null) */ - public final String tableCat; - - /** table schema (may be null) */ - public final String tableSchem; - - /** table name */ - public final String tableName; - - /** column name */ - public final String columnName; - - /** SQL type from java.sql.Types */ - public final int dataType; - - /** Data source dependent type name, for a UDT the type name is fully qualified */ - public final String typeName; - - /** - * column size. - * For char or date types this is the maximum number of characters, - * for numeric or decimal types this is precision. - */ - public final int columnSize; - - /** is not used. */ - public final int bufferLength; - - /** the number of fractional digits */ - public final int decimalDigits; - - /** Radix (typically either 10 or 2) */ - public final int numPrecRadix; - - /** is NULL allowed. */ - public final Nullable nullable; - - /** comment describing column (may be null) */ - public final String remarks; - - /** default value (may be null) */ - public final String columnDef; - - /** for char types the maximum number of bytes in the column */ - public final int charOctetLength; - - /** index of column in table (starting at 1) */ - public final int ordinalPosition; - - /** - * "NO" means column definitely does not allow NULL values; - * "YES" means the column might allow NULL values. - * An empty string means nobody knows. - */ - public final String isNullable; - - /** catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF) */ - public final String scopeCatalog; - - /** schema of table that is the scope of a reference attribute (null if the DATA_TYPE isn't REF) */ - public final String scopeSchema; - - /** table name that this the scope of a reference attribure (null if the DATA_TYPE isn't REF) */ - public final String scopeTable; - - /** - * source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types - * (null if DATA_TYPE isn't DISTINCT or user-generated REF) - */ - public final short sourceDataType; - - - /** - * インスタンスを生成する。 - * - * @param column {@link DatabaseMetaData#getColumns(String, String, String, String)}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public ColumnMeta(ResultSet column) { - Validate.notNull(column); - tableCat = ResultSetUtil.getString(column, "TABLE_CAT"); - tableSchem = ResultSetUtil.getString(column, "TABLE_SCHEM"); - tableName = ResultSetUtil.getString(column, "TABLE_NAME"); - columnName = ResultSetUtil.getString(column, "COLUMN_NAME"); - dataType = ResultSetUtil.getInt(column, "DATA_TYPE"); - typeName = ResultSetUtil.getString(column, "TYPE_NAME"); - columnSize = ResultSetUtil.getInt(column, "COLUMN_SIZE"); - bufferLength = ResultSetUtil.getInt(column, "BUFFER_LENGTH"); - decimalDigits = ResultSetUtil.getInt(column, "DECIMAL_DIGITS"); - numPrecRadix = ResultSetUtil.getInt(column, "NUM_PREC_RADIX"); - nullable = Nullable.getNullable(ResultSetUtil.getShort(column, "NULLABLE")); - remarks = ResultSetUtil.getString(column, "REMARKS"); - columnDef = ResultSetUtil.getString(column, "COLUMN_DEF"); - sqlDataType = ResultSetUtil.getInt(column, "SQL_DATA_TYPE"); - sqlDatetimeSub = ResultSetUtil.getInt(column, "SQL_DATETIME_SUB"); - charOctetLength = ResultSetUtil.getInt(column, "CHAR_OCTET_LENGTH"); - ordinalPosition = ResultSetUtil.getInt(column, "ORDINAL_POSITION"); - isNullable = ResultSetUtil.getString(column, "IS_NULLABLE"); // THINK enum化? - // IS_NULLABLE String => - // "NO" means column definitely does not allow NULL values; - // "YES" means the column might allow NULL values. - // An empty string means nobody knows. - - scopeCatalog = ResultSetUtil.getString(column, "SCOPE_CATLOG"); - scopeSchema = ResultSetUtil.getString(column, "SCOPE_SCHEMA"); - scopeTable = ResultSetUtil.getString(column, "SCOPE_TABLE"); - sourceDataType = ResultSetUtil.getShort(column, "SOURCE_DATA_TYPE"); - - assert tableName != null; - assert columnName != null; - assert typeName != null; - assert nullable != null; - assert isNullable != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - - /** - * カラムに対してNULLを設定可能かどうかを表す列挙型。 - * @author daisuke - */ - public static enum Nullable { - - /** might not allow NULL values */ - NO_NULLS(DatabaseMetaData.columnNoNulls), - - /** definitely allows NULL values */ - NULLABLE(DatabaseMetaData.columnNullable), - - /** nullability unknown */ - UNKNOWN(DatabaseMetaData.columnNullableUnknown); - - private static Nullable getNullable(short value) { - for (Nullable nullable : Nullable.values()) { - if (nullable.value == value) { - return nullable; - } - } - return null; - } - - - private final int value; - - - Nullable(int value) { - this.value = value; - } - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/25 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * DBから読み出したカラム情報の保持クラス。 + * + * <p>{@link DatabaseMetaData#getTables(String, String, String, String[])}の結果の一つを表す値クラス。</p> + * + * @author daisuke + */ +public class ColumnMeta { + + /** unused */ + public final int sqlDataType; + + /** unused */ + public final int sqlDatetimeSub; + + /** table catalog (may be null) */ + public final String tableCat; + + /** table schema (may be null) */ + public final String tableSchem; + + /** table name */ + public final String tableName; + + /** column name */ + public final String columnName; + + /** SQL type from java.sql.Types */ + public final int dataType; + + /** Data source dependent type name, for a UDT the type name is fully qualified */ + public final String typeName; + + /** + * column size. + * For char or date types this is the maximum number of characters, + * for numeric or decimal types this is precision. + */ + public final int columnSize; + + /** is not used. */ + public final int bufferLength; + + /** the number of fractional digits */ + public final int decimalDigits; + + /** Radix (typically either 10 or 2) */ + public final int numPrecRadix; + + /** is NULL allowed. */ + public final Nullable nullable; + + /** comment describing column (may be null) */ + public final String remarks; + + /** default value (may be null) */ + public final String columnDef; + + /** for char types the maximum number of bytes in the column */ + public final int charOctetLength; + + /** index of column in table (starting at 1) */ + public final int ordinalPosition; + + /** + * "NO" means column definitely does not allow NULL values; + * "YES" means the column might allow NULL values. + * An empty string means nobody knows. + */ + public final String isNullable; + + /** catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF) */ + public final String scopeCatalog; + + /** schema of table that is the scope of a reference attribute (null if the DATA_TYPE isn't REF) */ + public final String scopeSchema; + + /** table name that this the scope of a reference attribure (null if the DATA_TYPE isn't REF) */ + public final String scopeTable; + + /** + * source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types + * (null if DATA_TYPE isn't DISTINCT or user-generated REF) + */ + public final short sourceDataType; + + + /** + * インスタンスを生成する。 + * + * @param column {@link DatabaseMetaData#getColumns(String, String, String, String)}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public ColumnMeta(ResultSet column) { + Validate.notNull(column); + tableCat = ResultSetUtil.getString(column, "TABLE_CAT"); + tableSchem = ResultSetUtil.getString(column, "TABLE_SCHEM"); + tableName = ResultSetUtil.getString(column, "TABLE_NAME"); + columnName = ResultSetUtil.getString(column, "COLUMN_NAME"); + dataType = ResultSetUtil.getInt(column, "DATA_TYPE"); + typeName = ResultSetUtil.getString(column, "TYPE_NAME"); + columnSize = ResultSetUtil.getInt(column, "COLUMN_SIZE"); + bufferLength = ResultSetUtil.getInt(column, "BUFFER_LENGTH"); + decimalDigits = ResultSetUtil.getInt(column, "DECIMAL_DIGITS"); + numPrecRadix = ResultSetUtil.getInt(column, "NUM_PREC_RADIX"); + nullable = Nullable.getNullable(ResultSetUtil.getShort(column, "NULLABLE")); + remarks = ResultSetUtil.getString(column, "REMARKS"); + columnDef = ResultSetUtil.getString(column, "COLUMN_DEF"); + sqlDataType = ResultSetUtil.getInt(column, "SQL_DATA_TYPE"); + sqlDatetimeSub = ResultSetUtil.getInt(column, "SQL_DATETIME_SUB"); + charOctetLength = ResultSetUtil.getInt(column, "CHAR_OCTET_LENGTH"); + ordinalPosition = ResultSetUtil.getInt(column, "ORDINAL_POSITION"); + isNullable = ResultSetUtil.getString(column, "IS_NULLABLE"); // THINK enum化? + // IS_NULLABLE String => + // "NO" means column definitely does not allow NULL values; + // "YES" means the column might allow NULL values. + // An empty string means nobody knows. + + scopeCatalog = ResultSetUtil.getString(column, "SCOPE_CATLOG"); + scopeSchema = ResultSetUtil.getString(column, "SCOPE_SCHEMA"); + scopeTable = ResultSetUtil.getString(column, "SCOPE_TABLE"); + sourceDataType = ResultSetUtil.getShort(column, "SOURCE_DATA_TYPE"); + + assert tableName != null; + assert columnName != null; + assert typeName != null; + assert nullable != null; + assert isNullable != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + + + /** + * カラムに対してNULLを設定可能かどうかを表す列挙型。 + * @author daisuke + */ + public static enum Nullable { + + /** might not allow NULL values */ + NO_NULLS(DatabaseMetaData.columnNoNulls), + + /** definitely allows NULL values */ + NULLABLE(DatabaseMetaData.columnNullable), + + /** nullability unknown */ + UNKNOWN(DatabaseMetaData.columnNullableUnknown); + + private static Nullable getNullable(short value) { + for (Nullable nullable : Nullable.values()) { + if (nullable.value == value) { + return nullable; + } + } + return null; + } + + + private final int value; + + + Nullable(int value) { + this.value = value; + } + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ColumnMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ColumnPrivilegeMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ColumnPrivilegeMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ColumnPrivilegeMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,90 +1,90 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getColumnPrivileges(String, String, String, String)}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class ColumnPrivilegeMeta { - - /** table catalog (may be null) */ - public final String tableCat; - - /** table schema (may be null) */ - public final String tableSchem; - - /** table name */ - public final String tableName; - - /** column name */ - public final String columnName; - - /** grantor of access (may be null) */ - public final String grantor; - - /** grantee of access */ - public final String grantee; - - /** name of access (SELECT, INSERT, UPDATE, REFRENCES, ...) */ - public final String privilege; - - /** "YES" if grantee is permitted to grant to others; "NO" if not; null if unknown */ - public final String isGrantable; - - - /** - * インスタンスを生成する。 - * - * @param columnPrivileges {@link DatabaseMetaData#getColumnPrivileges(String, String, String, String)}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public ColumnPrivilegeMeta(ResultSet columnPrivileges) { - Validate.notNull(columnPrivileges); - tableCat = ResultSetUtil.getString(columnPrivileges, "TABLE_CAT"); - tableSchem = ResultSetUtil.getString(columnPrivileges, "TABLE_SCHEM"); - tableName = ResultSetUtil.getString(columnPrivileges, "TABLE_NAME"); - columnName = ResultSetUtil.getString(columnPrivileges, "COLUMN_NAME"); - grantor = ResultSetUtil.getString(columnPrivileges, "GRANTOR"); - grantee = ResultSetUtil.getString(columnPrivileges, "GRANTEE"); - privilege = ResultSetUtil.getString(columnPrivileges, "PRIVILEGE"); - isGrantable = ResultSetUtil.getString(columnPrivileges, "IS_GRANTABLE"); - - assert tableName != null; - assert columnName != null; - assert grantee != null; - assert privilege != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getColumnPrivileges(String, String, String, String)}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class ColumnPrivilegeMeta { + + /** table catalog (may be null) */ + public final String tableCat; + + /** table schema (may be null) */ + public final String tableSchem; + + /** table name */ + public final String tableName; + + /** column name */ + public final String columnName; + + /** grantor of access (may be null) */ + public final String grantor; + + /** grantee of access */ + public final String grantee; + + /** name of access (SELECT, INSERT, UPDATE, REFRENCES, ...) */ + public final String privilege; + + /** "YES" if grantee is permitted to grant to others; "NO" if not; null if unknown */ + public final String isGrantable; + + + /** + * インスタンスを生成する。 + * + * @param columnPrivileges {@link DatabaseMetaData#getColumnPrivileges(String, String, String, String)}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public ColumnPrivilegeMeta(ResultSet columnPrivileges) { + Validate.notNull(columnPrivileges); + tableCat = ResultSetUtil.getString(columnPrivileges, "TABLE_CAT"); + tableSchem = ResultSetUtil.getString(columnPrivileges, "TABLE_SCHEM"); + tableName = ResultSetUtil.getString(columnPrivileges, "TABLE_NAME"); + columnName = ResultSetUtil.getString(columnPrivileges, "COLUMN_NAME"); + grantor = ResultSetUtil.getString(columnPrivileges, "GRANTOR"); + grantee = ResultSetUtil.getString(columnPrivileges, "GRANTEE"); + privilege = ResultSetUtil.getString(columnPrivileges, "PRIVILEGE"); + isGrantable = ResultSetUtil.getString(columnPrivileges, "IS_GRANTABLE"); + + assert tableName != null; + assert columnName != null; + assert grantee != null; + assert privilege != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ColumnPrivilegeMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/IndexInfoMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/IndexInfoMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/IndexInfoMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,184 +1,184 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getIndexInfo(String, String, String, boolean, boolean)}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class IndexInfoMeta { - - /** table catalog (may be null) */ - public final String tableCat; - - /** table schema (may be null) */ - public final String tableSchem; - - /** table name */ - public final String tableName; - - /** Can index values be non-unique. false when TYPE is tableIndexStatistic */ - public final boolean nonUnique; - - /** index catalog (may be null); null when TYPE is tableIndexStatistic */ - public final String indexQualifier; - - /** index name; null when TYPE is tableIndexStatistic */ - public final String indexName; - - /** index type */ - public final IndexType type; - - /** column sequence number within index; zero when TYPE is tableIndexStatistic */ - public final short ordinalPosition; - - /** column name; null when TYPE is tableIndexStatistic */ - public final String columnName; - - /** - * column sort sequence, "A" => ascending, "D" => descending, - * may be null if sort sequence is not supported; null when TYPE is tableIndexStatistic - */ - public final SortSequence ascOrDesc; - - /** - * When TYPE is tableIndexStatistic, then this is the number of rows in the table; otherwise, - * it is the number of unique values in the index. - * */ - public final int cardinality; - - /** - * When TYPE is tableIndexStatisic then this is the number of pages used for the table, - * otherwise it is the number of pages used for the current index. - */ - public final int pages; - - /** Filter condition, if any. (may be null) */ - public final String filterCondition; - - - /** - * インスタンスを生成する。 - * - * @param indexInfo {@link DatabaseMetaData#getIndexInfo(String, String, String, boolean, boolean)}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public IndexInfoMeta(ResultSet indexInfo) { - Validate.notNull(indexInfo); - tableCat = ResultSetUtil.getString(indexInfo, "TABLE_CAT"); - tableSchem = ResultSetUtil.getString(indexInfo, "TABLE_SCHEM"); - tableName = ResultSetUtil.getString(indexInfo, "TABLE_NAME"); - nonUnique = ResultSetUtil.getBoolean(indexInfo, "NON_UNIQUE"); - indexQualifier = ResultSetUtil.getString(indexInfo, "INDEX_QUALIFIER"); - indexName = ResultSetUtil.getString(indexInfo, "INDEX_NAME"); - type = IndexType.getIndexType(ResultSetUtil.getShort(indexInfo, "TYPE")); - ordinalPosition = ResultSetUtil.getShort(indexInfo, "ORDINAL_POSITION"); - columnName = ResultSetUtil.getString(indexInfo, "COLUMN_NAME"); - ascOrDesc = SortSequence.getSortSequence(ResultSetUtil.getString(indexInfo, "ASC_OR_DESC")); - cardinality = ResultSetUtil.getInt(indexInfo, "CARDINALITY"); - pages = ResultSetUtil.getInt(indexInfo, "PAGES"); - filterCondition = ResultSetUtil.getString(indexInfo, "FILTER_CONDITION"); - - assert tableName != null; - assert type != null; - assert ascOrDesc != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - - /** - * インデックスの型を表す列挙型。 - * @author daisuke - */ - public static enum IndexType { - - /** this identifies table statistics that are returned in conjuction with a table's index descriptions */ - STATISTIC(DatabaseMetaData.tableIndexStatistic), - - /** this is a clustered index */ - CLUSTERED(DatabaseMetaData.tableIndexClustered), - - /** this is a hashed index */ - HASHED(DatabaseMetaData.tableIndexHashed), - - /** this is some other style of index */ - OTHER(DatabaseMetaData.tableIndexOther); - - private static IndexType getIndexType(short value) { - for (IndexType indexType : IndexType.values()) { - if (indexType.value == value) { - return indexType; - } - } - return null; - } - - - private int value; - - - IndexType(int value) { - this.value = value; - } - } - - /** - * 列ソートシーケンスを表す列挙型。 - * @author daisuke - */ - public static enum SortSequence { - - /** ascending */ - ASC("A"), - - /** descending */ - DESC("D"); - - private static SortSequence getSortSequence(String value) { - for (SortSequence sortSequence : SortSequence.values()) { - if (sortSequence.value.equals(value)) { - return sortSequence; - } - } - return null; - } - - - private String value; - - - SortSequence(String value) { - this.value = value; - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getIndexInfo(String, String, String, boolean, boolean)}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class IndexInfoMeta { + + /** table catalog (may be null) */ + public final String tableCat; + + /** table schema (may be null) */ + public final String tableSchem; + + /** table name */ + public final String tableName; + + /** Can index values be non-unique. false when TYPE is tableIndexStatistic */ + public final boolean nonUnique; + + /** index catalog (may be null); null when TYPE is tableIndexStatistic */ + public final String indexQualifier; + + /** index name; null when TYPE is tableIndexStatistic */ + public final String indexName; + + /** index type */ + public final IndexType type; + + /** column sequence number within index; zero when TYPE is tableIndexStatistic */ + public final short ordinalPosition; + + /** column name; null when TYPE is tableIndexStatistic */ + public final String columnName; + + /** + * column sort sequence, "A" => ascending, "D" => descending, + * may be null if sort sequence is not supported; null when TYPE is tableIndexStatistic + */ + public final SortSequence ascOrDesc; + + /** + * When TYPE is tableIndexStatistic, then this is the number of rows in the table; otherwise, + * it is the number of unique values in the index. + * */ + public final int cardinality; + + /** + * When TYPE is tableIndexStatisic then this is the number of pages used for the table, + * otherwise it is the number of pages used for the current index. + */ + public final int pages; + + /** Filter condition, if any. (may be null) */ + public final String filterCondition; + + + /** + * インスタンスを生成する。 + * + * @param indexInfo {@link DatabaseMetaData#getIndexInfo(String, String, String, boolean, boolean)}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public IndexInfoMeta(ResultSet indexInfo) { + Validate.notNull(indexInfo); + tableCat = ResultSetUtil.getString(indexInfo, "TABLE_CAT"); + tableSchem = ResultSetUtil.getString(indexInfo, "TABLE_SCHEM"); + tableName = ResultSetUtil.getString(indexInfo, "TABLE_NAME"); + nonUnique = ResultSetUtil.getBoolean(indexInfo, "NON_UNIQUE"); + indexQualifier = ResultSetUtil.getString(indexInfo, "INDEX_QUALIFIER"); + indexName = ResultSetUtil.getString(indexInfo, "INDEX_NAME"); + type = IndexType.getIndexType(ResultSetUtil.getShort(indexInfo, "TYPE")); + ordinalPosition = ResultSetUtil.getShort(indexInfo, "ORDINAL_POSITION"); + columnName = ResultSetUtil.getString(indexInfo, "COLUMN_NAME"); + ascOrDesc = SortSequence.getSortSequence(ResultSetUtil.getString(indexInfo, "ASC_OR_DESC")); + cardinality = ResultSetUtil.getInt(indexInfo, "CARDINALITY"); + pages = ResultSetUtil.getInt(indexInfo, "PAGES"); + filterCondition = ResultSetUtil.getString(indexInfo, "FILTER_CONDITION"); + + assert tableName != null; + assert type != null; + assert ascOrDesc != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + + + /** + * インデックスの型を表す列挙型。 + * @author daisuke + */ + public static enum IndexType { + + /** this identifies table statistics that are returned in conjuction with a table's index descriptions */ + STATISTIC(DatabaseMetaData.tableIndexStatistic), + + /** this is a clustered index */ + CLUSTERED(DatabaseMetaData.tableIndexClustered), + + /** this is a hashed index */ + HASHED(DatabaseMetaData.tableIndexHashed), + + /** this is some other style of index */ + OTHER(DatabaseMetaData.tableIndexOther); + + private static IndexType getIndexType(short value) { + for (IndexType indexType : IndexType.values()) { + if (indexType.value == value) { + return indexType; + } + } + return null; + } + + + private int value; + + + IndexType(int value) { + this.value = value; + } + } + + /** + * 列ソートシーケンスを表す列挙型。 + * @author daisuke + */ + public static enum SortSequence { + + /** ascending */ + ASC("A"), + + /** descending */ + DESC("D"); + + private static SortSequence getSortSequence(String value) { + for (SortSequence sortSequence : SortSequence.values()) { + if (sortSequence.value.equals(value)) { + return sortSequence; + } + } + return null; + } + + + private String value; + + + SortSequence(String value) { + this.value = value; + } + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/IndexInfoMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/KeyMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/KeyMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/KeyMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,191 +1,191 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getExportedKeys(String, String, String)}, - * {@link DatabaseMetaData#getImportedKeys(String, String, String)}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class KeyMeta { - - /** primary key table catalog being imported (may be null) */ - public final String pkTableCat; - - /** primary key table schema being imported (may be null) */ - public final String pkTableSchem; - - /** primary key table name being imported */ - public final String pkTableName; - - /** primary key column name being imported */ - public final String pkColumnName; - - /** foreign key table catalog (may be null) */ - public final String fkTableCat; - - /** foreign key table schema (may be null) */ - public final String fkTableSchem; - - /** foreign key table name */ - public final String fkTableName; - - /** foreign key column name */ - public final String fkColumnName; - - /** sequence number within a foreign key */ - public final short keySeq; - - /** What happens to a foreign key when the primary key is updated. */ - public final Rule updateRule; - - /** What happens to the foreign key when primary is deleted. */ - public final Rule deleteRule; - - /** foreign key name (may be null) */ - public final String fkName; - - /** primary key name (may be null) */ - public final String pkName; - - /** can the evaluation of foreign key */ - public final Deferrability deferrability; - - - /** - * インスタンスを生成する。 - * - * @param importedKey {@link DatabaseMetaData#getImportedKeys(String, String, String)}等の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public KeyMeta(ResultSet importedKey) { - Validate.notNull(importedKey); - pkTableCat = ResultSetUtil.getString(importedKey, "PKTABLE_CAT"); - pkTableSchem = ResultSetUtil.getString(importedKey, "PKTABLE_SCHEM"); - pkTableName = ResultSetUtil.getString(importedKey, "PKTABLE_NAME"); - pkColumnName = ResultSetUtil.getString(importedKey, "PKCOLUMN_NAME"); - fkTableCat = ResultSetUtil.getString(importedKey, "FKTABLE_CAT"); - fkTableSchem = ResultSetUtil.getString(importedKey, "FKTABLE_SCHEM"); - fkTableName = ResultSetUtil.getString(importedKey, "FKTABLE_NAME"); - fkColumnName = ResultSetUtil.getString(importedKey, "FKCOLUMN_NAME"); - keySeq = ResultSetUtil.getShort(importedKey, "KEY_SEQ"); - updateRule = Rule.getRule(ResultSetUtil.getShort(importedKey, "UPDATE_RULE")); - deleteRule = Rule.getRule(ResultSetUtil.getShort(importedKey, "DELETE_RULE")); - fkName = ResultSetUtil.getString(importedKey, "FK_NAME"); - pkName = ResultSetUtil.getString(importedKey, "PK_NAME"); - deferrability = Deferrability.getDeferrability(ResultSetUtil.getShort(importedKey, "DEFERRABILITY")); - - assert pkTableName != null; - assert pkColumnName != null; - assert fkTableName != null; - assert fkColumnName != null; - assert updateRule != null; - assert deleteRule != null; - assert deferrability != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - - /** - * 外部キーの制限の評価はコミットまで延期できるかどうかを表す列挙型。 - * @author daisuke - */ - public static enum Deferrability { - - /** see SQL92 for definition */ - INITIALLY_DEFERRED(DatabaseMetaData.importedKeyInitiallyDeferred), - - /** see SQL92 for definition */ - INITIALLY_IMMEDIATE(DatabaseMetaData.importedKeyInitiallyImmediate), - - /** see SQL92 for definition */ - NOT_DEFERRABLE(DatabaseMetaData.importedKeyNotDeferrable); - - private static Deferrability getDeferrability(int value) { - for (Deferrability deferrability : Deferrability.values()) { - if (deferrability.value == value) { - return deferrability; - } - } - return null; - } - - - private final int value; - - - Deferrability(int value) { - this.value = value; - } - } - - /** - * 主キーが更新/削除されるときに、外部キーに起こる内容を表す列挙型。 - * @author daisuke - */ - public static enum Rule { - - /** do not allow update/delete of primary key if it has been imported */ - NO_ACTION(DatabaseMetaData.importedKeyNoAction), - - /** change imported key to agree with primary key update / delete rows that import a deleted key */ - CASCADE(DatabaseMetaData.importedKeyCascade), - - /** change imported key to NULL if its primary key has been updated/deleted */ - SET_NULL(DatabaseMetaData.importedKeySetNull), - - /** change imported key to default values if its primary key has been updated/deleted */ - SET_DEFAULT(DatabaseMetaData.importedKeySetDefault), - - /** same as importedKeyNoAction (for ODBC 2.x compatibility) */ - RESTRICT(DatabaseMetaData.importedKeyRestrict); - - private static Rule getRule(short value) { - for (Rule rule : Rule.values()) { - if (rule.value == value) { - return rule; - } - } - return null; - } - - - private final int value; - - - Rule(int value) { - this.value = value; - } - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getExportedKeys(String, String, String)}, + * {@link DatabaseMetaData#getImportedKeys(String, String, String)}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class KeyMeta { + + /** primary key table catalog being imported (may be null) */ + public final String pkTableCat; + + /** primary key table schema being imported (may be null) */ + public final String pkTableSchem; + + /** primary key table name being imported */ + public final String pkTableName; + + /** primary key column name being imported */ + public final String pkColumnName; + + /** foreign key table catalog (may be null) */ + public final String fkTableCat; + + /** foreign key table schema (may be null) */ + public final String fkTableSchem; + + /** foreign key table name */ + public final String fkTableName; + + /** foreign key column name */ + public final String fkColumnName; + + /** sequence number within a foreign key */ + public final short keySeq; + + /** What happens to a foreign key when the primary key is updated. */ + public final Rule updateRule; + + /** What happens to the foreign key when primary is deleted. */ + public final Rule deleteRule; + + /** foreign key name (may be null) */ + public final String fkName; + + /** primary key name (may be null) */ + public final String pkName; + + /** can the evaluation of foreign key */ + public final Deferrability deferrability; + + + /** + * インスタンスを生成する。 + * + * @param importedKey {@link DatabaseMetaData#getImportedKeys(String, String, String)}等の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public KeyMeta(ResultSet importedKey) { + Validate.notNull(importedKey); + pkTableCat = ResultSetUtil.getString(importedKey, "PKTABLE_CAT"); + pkTableSchem = ResultSetUtil.getString(importedKey, "PKTABLE_SCHEM"); + pkTableName = ResultSetUtil.getString(importedKey, "PKTABLE_NAME"); + pkColumnName = ResultSetUtil.getString(importedKey, "PKCOLUMN_NAME"); + fkTableCat = ResultSetUtil.getString(importedKey, "FKTABLE_CAT"); + fkTableSchem = ResultSetUtil.getString(importedKey, "FKTABLE_SCHEM"); + fkTableName = ResultSetUtil.getString(importedKey, "FKTABLE_NAME"); + fkColumnName = ResultSetUtil.getString(importedKey, "FKCOLUMN_NAME"); + keySeq = ResultSetUtil.getShort(importedKey, "KEY_SEQ"); + updateRule = Rule.getRule(ResultSetUtil.getShort(importedKey, "UPDATE_RULE")); + deleteRule = Rule.getRule(ResultSetUtil.getShort(importedKey, "DELETE_RULE")); + fkName = ResultSetUtil.getString(importedKey, "FK_NAME"); + pkName = ResultSetUtil.getString(importedKey, "PK_NAME"); + deferrability = Deferrability.getDeferrability(ResultSetUtil.getShort(importedKey, "DEFERRABILITY")); + + assert pkTableName != null; + assert pkColumnName != null; + assert fkTableName != null; + assert fkColumnName != null; + assert updateRule != null; + assert deleteRule != null; + assert deferrability != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + + + /** + * 外部キーの制限の評価はコミットまで延期できるかどうかを表す列挙型。 + * @author daisuke + */ + public static enum Deferrability { + + /** see SQL92 for definition */ + INITIALLY_DEFERRED(DatabaseMetaData.importedKeyInitiallyDeferred), + + /** see SQL92 for definition */ + INITIALLY_IMMEDIATE(DatabaseMetaData.importedKeyInitiallyImmediate), + + /** see SQL92 for definition */ + NOT_DEFERRABLE(DatabaseMetaData.importedKeyNotDeferrable); + + private static Deferrability getDeferrability(int value) { + for (Deferrability deferrability : Deferrability.values()) { + if (deferrability.value == value) { + return deferrability; + } + } + return null; + } + + + private final int value; + + + Deferrability(int value) { + this.value = value; + } + } + + /** + * 主キーが更新/削除されるときに、外部キーに起こる内容を表す列挙型。 + * @author daisuke + */ + public static enum Rule { + + /** do not allow update/delete of primary key if it has been imported */ + NO_ACTION(DatabaseMetaData.importedKeyNoAction), + + /** change imported key to agree with primary key update / delete rows that import a deleted key */ + CASCADE(DatabaseMetaData.importedKeyCascade), + + /** change imported key to NULL if its primary key has been updated/deleted */ + SET_NULL(DatabaseMetaData.importedKeySetNull), + + /** change imported key to default values if its primary key has been updated/deleted */ + SET_DEFAULT(DatabaseMetaData.importedKeySetDefault), + + /** same as importedKeyNoAction (for ODBC 2.x compatibility) */ + RESTRICT(DatabaseMetaData.importedKeyRestrict); + + private static Rule getRule(short value) { + for (Rule rule : Rule.values()) { + if (rule.value == value) { + return rule; + } + } + return null; + } + + + private final int value; + + + Rule(int value) { + this.value = value; + } + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/KeyMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/PrimaryKeyMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/PrimaryKeyMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/PrimaryKeyMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,79 +1,79 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getPrimaryKeys(String, String, String)}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class PrimaryKeyMeta { - - /** table catalog (may be null) */ - public final String tableCat; - - /** table schema (may be null) */ - public final String tableSchem; - - /** table name */ - public final String tableName; - - /** column name */ - public final String columnName; - - /** sequence number within primary key */ - public final short keySeq; - - /** primary key name (may be null) */ - public final String pkName; - - - /** - * インスタンスを生成する。 - * - * @param primaryKey {@link DatabaseMetaData#getPrimaryKeys(String, String, String)}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public PrimaryKeyMeta(ResultSet primaryKey) { - Validate.notNull(primaryKey); - tableCat = ResultSetUtil.getString(primaryKey, "TABLE_CAT"); - tableSchem = ResultSetUtil.getString(primaryKey, "TABLE_SCHEM"); - tableName = ResultSetUtil.getString(primaryKey, "TABLE_NAME"); - columnName = ResultSetUtil.getString(primaryKey, "COLUMN_NAME"); - keySeq = ResultSetUtil.getShort(primaryKey, "KEY_SEQ"); - pkName = ResultSetUtil.getString(primaryKey, "PK_NAME"); - - assert tableName != null; - assert columnName != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getPrimaryKeys(String, String, String)}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class PrimaryKeyMeta { + + /** table catalog (may be null) */ + public final String tableCat; + + /** table schema (may be null) */ + public final String tableSchem; + + /** table name */ + public final String tableName; + + /** column name */ + public final String columnName; + + /** sequence number within primary key */ + public final short keySeq; + + /** primary key name (may be null) */ + public final String pkName; + + + /** + * インスタンスを生成する。 + * + * @param primaryKey {@link DatabaseMetaData#getPrimaryKeys(String, String, String)}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public PrimaryKeyMeta(ResultSet primaryKey) { + Validate.notNull(primaryKey); + tableCat = ResultSetUtil.getString(primaryKey, "TABLE_CAT"); + tableSchem = ResultSetUtil.getString(primaryKey, "TABLE_SCHEM"); + tableName = ResultSetUtil.getString(primaryKey, "TABLE_NAME"); + columnName = ResultSetUtil.getString(primaryKey, "COLUMN_NAME"); + keySeq = ResultSetUtil.getShort(primaryKey, "KEY_SEQ"); + pkName = ResultSetUtil.getString(primaryKey, "PK_NAME"); + + assert tableName != null; + assert columnName != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/PrimaryKeyMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ProcedureColumnsMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ProcedureColumnsMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ProcedureColumnsMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,182 +1,182 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class ProcedureColumnsMeta { - - /** procedure catalog (may be null) */ - public final String procedureCat; - - /** procedure schema (may be null) */ - public final String procedureSchem; - - /** procedure name */ - public final String procedureName; - - /** column/parameter name */ - public final String columnName; - - /** kind of column/parameter */ - public final ColumnType columnType; - - /** SQL type from java.sql.Types */ - public final int dataType; - - /** SQL type name, for a UDT type the type name is fully qualified */ - public final String typeName; - - /** precision */ - public final int precision; - - /** length in bytes of data */ - public final int length; - - /** scale */ - public final short scale; - - /** radix */ - public final short radix; - - /** can it contain NULL. */ - public final Nullable nullable; - - - /** - * インスタンスを生成する。 - * - * @param procedureColumn {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public ProcedureColumnsMeta(ResultSet procedureColumn) { - Validate.notNull(procedureColumn); - procedureCat = ResultSetUtil.getString(procedureColumn, "PROCEDURE_CAT"); - procedureSchem = ResultSetUtil.getString(procedureColumn, "PROCEDURE_SCHEM"); - procedureName = ResultSetUtil.getString(procedureColumn, "PROCEDURE_NAME"); - columnName = ResultSetUtil.getString(procedureColumn, "COLUMN_NAME"); - columnType = ColumnType.getColumnType(ResultSetUtil.getShort(procedureColumn, "COLUMN_TYPE")); - dataType = ResultSetUtil.getInt(procedureColumn, "DATA_TYPE"); - typeName = ResultSetUtil.getString(procedureColumn, "TYPE_NAME"); - precision = ResultSetUtil.getInt(procedureColumn, "PRECISION"); - length = ResultSetUtil.getInt(procedureColumn, "LENGTH"); - scale = ResultSetUtil.getShort(procedureColumn, "SCALE"); - radix = ResultSetUtil.getShort(procedureColumn, "RADIX"); - nullable = Nullable.getNullable(ResultSetUtil.getShort(procedureColumn, "NULLABLE")); - - assert procedureName != null; - assert columnName != null; - assert columnType != null; - assert typeName != null; - assert nullable != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - - /** - * 列の種類/パラメータを表す列挙型。 - * @author daisuke - */ - public static enum ColumnType { - - /** nobody knows */ - UNKNOWN(DatabaseMetaData.procedureColumnUnknown), - - /** IN parameter */ - IN(DatabaseMetaData.procedureColumnIn), - - /** INOUT parameter */ - INOUT(DatabaseMetaData.procedureColumnInOut), - - /** OUT parameter */ - OUT(DatabaseMetaData.procedureColumnOut), - - /** procedure return value */ - RETURN(DatabaseMetaData.procedureColumnReturn), - - /** result column in ResultSet */ - RESULT(DatabaseMetaData.procedureColumnResult); - - private static ColumnType getColumnType(short value) { - for (ColumnType columnType : ColumnType.values()) { - if (columnType.value == value) { - return columnType; - } - } - return null; - } - - - private int value; - - - ColumnType(int value) { - this.value = value; - } - } - - /** - * NULL を含めることができるかを表す列挙型。 - * @author daisuke - */ - public static enum Nullable { - - /** does not allow NULL values */ - NO_NULLS(DatabaseMetaData.procedureNoNulls), - - /** allows NULL values */ - NULLABLE(DatabaseMetaData.procedureNullable), - - /** nullability unknown */ - UNKNOWN(DatabaseMetaData.procedureNullableUnknown); - - private static Nullable getNullable(short value) { - for (Nullable nullable : Nullable.values()) { - if (nullable.value == value) { - return nullable; - } - } - return null; - } - - - private final int value; - - - Nullable(int value) { - this.value = value; - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class ProcedureColumnsMeta { + + /** procedure catalog (may be null) */ + public final String procedureCat; + + /** procedure schema (may be null) */ + public final String procedureSchem; + + /** procedure name */ + public final String procedureName; + + /** column/parameter name */ + public final String columnName; + + /** kind of column/parameter */ + public final ColumnType columnType; + + /** SQL type from java.sql.Types */ + public final int dataType; + + /** SQL type name, for a UDT type the type name is fully qualified */ + public final String typeName; + + /** precision */ + public final int precision; + + /** length in bytes of data */ + public final int length; + + /** scale */ + public final short scale; + + /** radix */ + public final short radix; + + /** can it contain NULL. */ + public final Nullable nullable; + + + /** + * インスタンスを生成する。 + * + * @param procedureColumn {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public ProcedureColumnsMeta(ResultSet procedureColumn) { + Validate.notNull(procedureColumn); + procedureCat = ResultSetUtil.getString(procedureColumn, "PROCEDURE_CAT"); + procedureSchem = ResultSetUtil.getString(procedureColumn, "PROCEDURE_SCHEM"); + procedureName = ResultSetUtil.getString(procedureColumn, "PROCEDURE_NAME"); + columnName = ResultSetUtil.getString(procedureColumn, "COLUMN_NAME"); + columnType = ColumnType.getColumnType(ResultSetUtil.getShort(procedureColumn, "COLUMN_TYPE")); + dataType = ResultSetUtil.getInt(procedureColumn, "DATA_TYPE"); + typeName = ResultSetUtil.getString(procedureColumn, "TYPE_NAME"); + precision = ResultSetUtil.getInt(procedureColumn, "PRECISION"); + length = ResultSetUtil.getInt(procedureColumn, "LENGTH"); + scale = ResultSetUtil.getShort(procedureColumn, "SCALE"); + radix = ResultSetUtil.getShort(procedureColumn, "RADIX"); + nullable = Nullable.getNullable(ResultSetUtil.getShort(procedureColumn, "NULLABLE")); + + assert procedureName != null; + assert columnName != null; + assert columnType != null; + assert typeName != null; + assert nullable != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + + + /** + * 列の種類/パラメータを表す列挙型。 + * @author daisuke + */ + public static enum ColumnType { + + /** nobody knows */ + UNKNOWN(DatabaseMetaData.procedureColumnUnknown), + + /** IN parameter */ + IN(DatabaseMetaData.procedureColumnIn), + + /** INOUT parameter */ + INOUT(DatabaseMetaData.procedureColumnInOut), + + /** OUT parameter */ + OUT(DatabaseMetaData.procedureColumnOut), + + /** procedure return value */ + RETURN(DatabaseMetaData.procedureColumnReturn), + + /** result column in ResultSet */ + RESULT(DatabaseMetaData.procedureColumnResult); + + private static ColumnType getColumnType(short value) { + for (ColumnType columnType : ColumnType.values()) { + if (columnType.value == value) { + return columnType; + } + } + return null; + } + + + private int value; + + + ColumnType(int value) { + this.value = value; + } + } + + /** + * NULL を含めることができるかを表す列挙型。 + * @author daisuke + */ + public static enum Nullable { + + /** does not allow NULL values */ + NO_NULLS(DatabaseMetaData.procedureNoNulls), + + /** allows NULL values */ + NULLABLE(DatabaseMetaData.procedureNullable), + + /** nullability unknown */ + UNKNOWN(DatabaseMetaData.procedureNullableUnknown); + + private static Nullable getNullable(short value) { + for (Nullable nullable : Nullable.values()) { + if (nullable.value == value) { + return nullable; + } + } + return null; + } + + + private final int value; + + + Nullable(int value) { + this.value = value; + } + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ProcedureColumnsMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ProcedureMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ProcedureMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ProcedureMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,109 +1,109 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getProcedures(String, String, String)}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class ProcedureMeta { - - /** procedure catalog (may be null) */ - public final String procedureCat; - - /** procedure schema (may be null) */ - public final String procedureSchem; - - /** procedure name */ - public final String procedureName; - - /** explanatory comment on the procedure */ - public final String remarks; - - /** kind of procedure */ - public final ProcedureType procedureType; - - - /** - * インスタンスを生成する。 - * - * @param procedure {@link DatabaseMetaData#getProcedures(String, String, String)}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public ProcedureMeta(ResultSet procedure) { - Validate.notNull(procedure); - procedureCat = ResultSetUtil.getString(procedure, "PROCEDURE_CAT"); - procedureSchem = ResultSetUtil.getString(procedure, "PROCEDURE_SCHEM"); - procedureName = ResultSetUtil.getString(procedure, "PROCEDURE_NAME"); - remarks = ResultSetUtil.getString(procedure, "REMARKS"); - procedureType = ProcedureType.getProcedureType(ResultSetUtil.getShort(procedure, "PROCEDURE_TYPE")); - - assert procedureName != null; - assert procedureType != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - - /** - * プロシージャの種類を表す列挙型。 - * @author daisuke - */ - public static enum ProcedureType { - - /** May return a result */ - RESULT_UNKNOWN(DatabaseMetaData.procedureResultUnknown), - - /** Does not return a result */ - NO_RESULT(DatabaseMetaData.procedureNoResult), - - /** Returns a result */ - RETURNS_RESULT(DatabaseMetaData.procedureReturnsResult); - - private static ProcedureType getProcedureType(short value) { - for (ProcedureType procedureType : ProcedureType.values()) { - if (procedureType.value == value) { - return procedureType; - } - } - return null; - } - - - private int value; - - - ProcedureType(int value) { - this.value = value; - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getProcedures(String, String, String)}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class ProcedureMeta { + + /** procedure catalog (may be null) */ + public final String procedureCat; + + /** procedure schema (may be null) */ + public final String procedureSchem; + + /** procedure name */ + public final String procedureName; + + /** explanatory comment on the procedure */ + public final String remarks; + + /** kind of procedure */ + public final ProcedureType procedureType; + + + /** + * インスタンスを生成する。 + * + * @param procedure {@link DatabaseMetaData#getProcedures(String, String, String)}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public ProcedureMeta(ResultSet procedure) { + Validate.notNull(procedure); + procedureCat = ResultSetUtil.getString(procedure, "PROCEDURE_CAT"); + procedureSchem = ResultSetUtil.getString(procedure, "PROCEDURE_SCHEM"); + procedureName = ResultSetUtil.getString(procedure, "PROCEDURE_NAME"); + remarks = ResultSetUtil.getString(procedure, "REMARKS"); + procedureType = ProcedureType.getProcedureType(ResultSetUtil.getShort(procedure, "PROCEDURE_TYPE")); + + assert procedureName != null; + assert procedureType != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + + + /** + * プロシージャの種類を表す列挙型。 + * @author daisuke + */ + public static enum ProcedureType { + + /** May return a result */ + RESULT_UNKNOWN(DatabaseMetaData.procedureResultUnknown), + + /** Does not return a result */ + NO_RESULT(DatabaseMetaData.procedureNoResult), + + /** Returns a result */ + RETURNS_RESULT(DatabaseMetaData.procedureReturnsResult); + + private static ProcedureType getProcedureType(short value) { + for (ProcedureType procedureType : ProcedureType.values()) { + if (procedureType.value == value) { + return procedureType; + } + } + return null; + } + + + private int value; + + + ProcedureType(int value) { + this.value = value; + } + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/ProcedureMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SchemaMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SchemaMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SchemaMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,63 +1,63 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getSchemas()}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class SchemaMeta { - - /** schema name */ - public final String tableSchem; - - /** catalog name (may be null) */ - public final String tableCat; - - - /** - * インスタンスを生成する。 - * - * @param schema {@link DatabaseMetaData#getSchemas()}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public SchemaMeta(ResultSet schema) { - Validate.notNull(schema); - tableSchem = ResultSetUtil.getString(schema, "TABLE_SCHEM"); - tableCat = ResultSetUtil.getString(schema, "TABLE_CAT"); - - assert tableSchem != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getSchemas()}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class SchemaMeta { + + /** schema name */ + public final String tableSchem; + + /** catalog name (may be null) */ + public final String tableCat; + + + /** + * インスタンスを生成する。 + * + * @param schema {@link DatabaseMetaData#getSchemas()}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public SchemaMeta(ResultSet schema) { + Validate.notNull(schema); + tableSchem = ResultSetUtil.getString(schema, "TABLE_SCHEM"); + tableCat = ResultSetUtil.getString(schema, "TABLE_CAT"); + + assert tableSchem != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SchemaMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SuperTableMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SuperTableMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SuperTableMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,72 +1,72 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getSuperTables(String, String, String)}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class SuperTableMeta { - - /** the type's catalog (may be null) */ - public final String tableCat; - - /** type's schema (may be null) */ - public final String tableSchem; - - /** type name */ - public final String tableName; - - /** the direct super type's name */ - public final String supertableName; - - - /** - * インスタンスを生成する。 - * - * @param superTable {@link DatabaseMetaData#getSuperTables(String, String, String)}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public SuperTableMeta(ResultSet superTable) { - Validate.notNull(superTable); - tableCat = ResultSetUtil.getString(superTable, "TABLE_CAT"); - tableSchem = ResultSetUtil.getString(superTable, "TABLE_SCHEM"); - tableName = ResultSetUtil.getString(superTable, "TABLE_NAME"); - supertableName = ResultSetUtil.getString(superTable, "SUPERTABLE_NAME"); - - assert tableName != null; - assert supertableName != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getSuperTables(String, String, String)}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class SuperTableMeta { + + /** the type's catalog (may be null) */ + public final String tableCat; + + /** type's schema (may be null) */ + public final String tableSchem; + + /** type name */ + public final String tableName; + + /** the direct super type's name */ + public final String supertableName; + + + /** + * インスタンスを生成する。 + * + * @param superTable {@link DatabaseMetaData#getSuperTables(String, String, String)}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public SuperTableMeta(ResultSet superTable) { + Validate.notNull(superTable); + tableCat = ResultSetUtil.getString(superTable, "TABLE_CAT"); + tableSchem = ResultSetUtil.getString(superTable, "TABLE_SCHEM"); + tableName = ResultSetUtil.getString(superTable, "TABLE_NAME"); + supertableName = ResultSetUtil.getString(superTable, "SUPERTABLE_NAME"); + + assert tableName != null; + assert supertableName != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SuperTableMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SuperTypeMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SuperTypeMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SuperTypeMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,80 +1,80 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getSuperTypes(String, String, String)}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class SuperTypeMeta { - - /** the UDT's catalog (may be null) */ - public final String typeCat; - - /** UDT's schema (may be null) */ - public final String typeSchem; - - /** type name of the UDT */ - public final String typeName; - - /** the direct super type's catalog (may be null) */ - public final String supertypeCat; - - /** the direct super type's schema (may be null) */ - public final String supertypeSchem; - - /** the direct super type's name */ - public final String supertypeName; - - - /** - * インスタンスを生成する。 - * - * @param superType {@link DatabaseMetaData#getSuperTypes(String, String, String)}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public SuperTypeMeta(ResultSet superType) { - Validate.notNull(superType); - typeCat = ResultSetUtil.getString(superType, "TYPE_CAT"); - typeSchem = ResultSetUtil.getString(superType, "TYPE_SCHEM"); - typeName = ResultSetUtil.getString(superType, "TYPE_NAME"); - supertypeCat = ResultSetUtil.getString(superType, "SUPERTYPE_CAT"); - supertypeSchem = ResultSetUtil.getString(superType, "SUPERTYPE_SCHEM"); - supertypeName = ResultSetUtil.getString(superType, "SUPERTYPE_NAME"); - - assert typeName != null; - assert supertypeName != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getSuperTypes(String, String, String)}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class SuperTypeMeta { + + /** the UDT's catalog (may be null) */ + public final String typeCat; + + /** UDT's schema (may be null) */ + public final String typeSchem; + + /** type name of the UDT */ + public final String typeName; + + /** the direct super type's catalog (may be null) */ + public final String supertypeCat; + + /** the direct super type's schema (may be null) */ + public final String supertypeSchem; + + /** the direct super type's name */ + public final String supertypeName; + + + /** + * インスタンスを生成する。 + * + * @param superType {@link DatabaseMetaData#getSuperTypes(String, String, String)}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public SuperTypeMeta(ResultSet superType) { + Validate.notNull(superType); + typeCat = ResultSetUtil.getString(superType, "TYPE_CAT"); + typeSchem = ResultSetUtil.getString(superType, "TYPE_SCHEM"); + typeName = ResultSetUtil.getString(superType, "TYPE_NAME"); + supertypeCat = ResultSetUtil.getString(superType, "SUPERTYPE_CAT"); + supertypeSchem = ResultSetUtil.getString(superType, "SUPERTYPE_SCHEM"); + supertypeName = ResultSetUtil.getString(superType, "SUPERTYPE_NAME"); + + assert typeName != null; + assert supertypeName != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/SuperTypeMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TableMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TableMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TableMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,122 +1,122 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/25 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * DBから読み出したテーブル情報の保持クラス。 - * - * <p>{@link DatabaseMetaData#getTables(String, String, String, String[])}の結果の一つを表す値クラス。</p> - * - * @author daisuke - */ -public class TableMeta { - - /** table catalog (may be null) */ - public final String tableCat; - - /** table schema (may be null) */ - public final String tableSchem; - - /** table name */ - public final String tableName; - - /** - * table type. - * Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". - */ - public final String tableType; - - /** explanatory comment on the table */ - public final String remarks; - - /** the types catalog (may be null) */ - public final String typeCat; - - /** the types schema (may be null) */ - public final String typeSchem; - - /** type name (may be null) */ - public final String typeName; - - /** name of the designated "identifier" column of a typed table (may be null) */ - public final String selfReferencingColName; - - /** specifies how values in SELF_REFERENCING_COL_NAME are created (may be null) */ - public final RefGeneration refGeneration; - - - /** - * インスタンスを生成する。 - * - * @param table {@link DatabaseMetaData#getTables(String, String, String, String[])}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public TableMeta(ResultSet table) { - Validate.notNull(table); - tableCat = ResultSetUtil.getString(table, "TABLE_CAT"); - tableSchem = ResultSetUtil.getString(table, "TABLE_SCHEM"); - tableName = ResultSetUtil.getString(table, "TABLE_NAME"); - tableType = ResultSetUtil.getString(table, "TABLE_TYPE"); - remarks = ResultSetUtil.getString(table, "REMARKS"); - typeCat = ResultSetUtil.getString(table, "TYPE_CAT"); - typeSchem = ResultSetUtil.getString(table, "TYPE_SCHEM"); - typeName = ResultSetUtil.getString(table, "TYPE_NAME"); - selfReferencingColName = ResultSetUtil.getString(table, "SELF_REFERENCING_COL_NAME"); - - String refGenerationString = ResultSetUtil.getString(table, "REF_GENERATION"); - if (refGenerationString == null) { - refGeneration = null; - } else { - refGeneration = RefGeneration.valueOf(refGenerationString); - } - - assert tableName != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - - /** - * ELF_REFERENCING_COL_NAME の値の作成方法を示す列挙型。 - * @author daisuke - */ - public enum RefGeneration { - /** システムテーブル */ - SYSTEM, - - /** ユーザテーブル */ - USER, - - /** 派生テーブル */ - DERIVED - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/25 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * DBから読み出したテーブル情報の保持クラス。 + * + * <p>{@link DatabaseMetaData#getTables(String, String, String, String[])}の結果の一つを表す値クラス。</p> + * + * @author daisuke + */ +public class TableMeta { + + /** table catalog (may be null) */ + public final String tableCat; + + /** table schema (may be null) */ + public final String tableSchem; + + /** table name */ + public final String tableName; + + /** + * table type. + * Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". + */ + public final String tableType; + + /** explanatory comment on the table */ + public final String remarks; + + /** the types catalog (may be null) */ + public final String typeCat; + + /** the types schema (may be null) */ + public final String typeSchem; + + /** type name (may be null) */ + public final String typeName; + + /** name of the designated "identifier" column of a typed table (may be null) */ + public final String selfReferencingColName; + + /** specifies how values in SELF_REFERENCING_COL_NAME are created (may be null) */ + public final RefGeneration refGeneration; + + + /** + * インスタンスを生成する。 + * + * @param table {@link DatabaseMetaData#getTables(String, String, String, String[])}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public TableMeta(ResultSet table) { + Validate.notNull(table); + tableCat = ResultSetUtil.getString(table, "TABLE_CAT"); + tableSchem = ResultSetUtil.getString(table, "TABLE_SCHEM"); + tableName = ResultSetUtil.getString(table, "TABLE_NAME"); + tableType = ResultSetUtil.getString(table, "TABLE_TYPE"); + remarks = ResultSetUtil.getString(table, "REMARKS"); + typeCat = ResultSetUtil.getString(table, "TYPE_CAT"); + typeSchem = ResultSetUtil.getString(table, "TYPE_SCHEM"); + typeName = ResultSetUtil.getString(table, "TYPE_NAME"); + selfReferencingColName = ResultSetUtil.getString(table, "SELF_REFERENCING_COL_NAME"); + + String refGenerationString = ResultSetUtil.getString(table, "REF_GENERATION"); + if (refGenerationString == null) { + refGeneration = null; + } else { + refGeneration = RefGeneration.valueOf(refGenerationString); + } + + assert tableName != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + + + /** + * ELF_REFERENCING_COL_NAME の値の作成方法を示す列挙型。 + * @author daisuke + */ + public enum RefGeneration { + /** システムテーブル */ + SYSTEM, + + /** ユーザテーブル */ + USER, + + /** 派生テーブル */ + DERIVED + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TableMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TablePrivilegeMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TablePrivilegeMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TablePrivilegeMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,85 +1,85 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getTablePrivileges(String, String, String)}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class TablePrivilegeMeta { - - /** table catalog (may be null) */ - public final String tableCat; - - /** table schema (may be null) */ - public final String tableSchem; - - /** table name */ - public final String tableName; - - /** grantor of access (may be null) */ - public final String grantor; - - /** grantee of access */ - public final String grantee; - - /** name of access (SELECT, INSERT, UPDATE, REFRENCES, ...) */ - public final String privilege; - - /** "YES" if grantee is permitted to grant to others; "NO" if not; null if unknown */ - public final String isGrantable; - - - /** - * インスタンスを生成する。 - * - * @param tablePrivilege {@link DatabaseMetaData#getTablePrivileges(String, String, String)}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public TablePrivilegeMeta(ResultSet tablePrivilege) { - Validate.notNull(tablePrivilege); - tableCat = ResultSetUtil.getString(tablePrivilege, "TABLE_CAT"); - tableSchem = ResultSetUtil.getString(tablePrivilege, "TABLE_SCHEM"); - tableName = ResultSetUtil.getString(tablePrivilege, "TABLE_NAME"); - grantor = ResultSetUtil.getString(tablePrivilege, "GRANTOR"); - grantee = ResultSetUtil.getString(tablePrivilege, "GRANTEE"); - privilege = ResultSetUtil.getString(tablePrivilege, "PRIVILEGE"); - isGrantable = ResultSetUtil.getString(tablePrivilege, "IS_GRANTABLE"); - - assert tableName != null; - assert grantee != null; - assert privilege != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getTablePrivileges(String, String, String)}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class TablePrivilegeMeta { + + /** table catalog (may be null) */ + public final String tableCat; + + /** table schema (may be null) */ + public final String tableSchem; + + /** table name */ + public final String tableName; + + /** grantor of access (may be null) */ + public final String grantor; + + /** grantee of access */ + public final String grantee; + + /** name of access (SELECT, INSERT, UPDATE, REFRENCES, ...) */ + public final String privilege; + + /** "YES" if grantee is permitted to grant to others; "NO" if not; null if unknown */ + public final String isGrantable; + + + /** + * インスタンスを生成する。 + * + * @param tablePrivilege {@link DatabaseMetaData#getTablePrivileges(String, String, String)}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public TablePrivilegeMeta(ResultSet tablePrivilege) { + Validate.notNull(tablePrivilege); + tableCat = ResultSetUtil.getString(tablePrivilege, "TABLE_CAT"); + tableSchem = ResultSetUtil.getString(tablePrivilege, "TABLE_SCHEM"); + tableName = ResultSetUtil.getString(tablePrivilege, "TABLE_NAME"); + grantor = ResultSetUtil.getString(tablePrivilege, "GRANTOR"); + grantee = ResultSetUtil.getString(tablePrivilege, "GRANTEE"); + privilege = ResultSetUtil.getString(tablePrivilege, "PRIVILEGE"); + isGrantable = ResultSetUtil.getString(tablePrivilege, "IS_GRANTABLE"); + + assert tableName != null; + assert grantee != null; + assert privilege != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TablePrivilegeMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TableTypeMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TableTypeMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TableTypeMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,62 +1,62 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getTableTypes()}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class TableTypeMeta { - - /** - * table type. - * Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". - */ - public final String tableType; - - - /** - * インスタンスを生成する。 - * - * @param tableType {@link DatabaseMetaData#getTableTypes()}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public TableTypeMeta(ResultSet tableType) { - Validate.notNull(tableType); - this.tableType = ResultSetUtil.getString(tableType, "TABLE_TYPE"); - - assert this.tableType != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getTableTypes()}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class TableTypeMeta { + + /** + * table type. + * Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". + */ + public final String tableType; + + + /** + * インスタンスを生成する。 + * + * @param tableType {@link DatabaseMetaData#getTableTypes()}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public TableTypeMeta(ResultSet tableType) { + Validate.notNull(tableType); + this.tableType = ResultSetUtil.getString(tableType, "TABLE_TYPE"); + + assert this.tableType != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TableTypeMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TypeInfoMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TypeInfoMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TypeInfoMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,215 +1,215 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/25 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * DBから読み出したデータ型情報の保持クラス。 - * - * <p>{@link DatabaseMetaData#getTypeInfo()}の結果の一つを表す値クラス。</p> - * - * @author daisuke - */ -public class TypeInfoMeta { - - /** Type name */ - public final String typeName; - - /** SQL data type from java.sql.Types */ - public final int dataType; - - /** maximum precision */ - public final int precision; - - /** prefix used to quote a literal (may be null) */ - public final String literalPrefix; - - /** suffix used to quote a literal (may be null) */ - public final String literalSuffix; - - /** parameters used in creating the type (may be null) */ - public final String createParams; - - /** can you use NULL for this type. */ - public final Nullable nullable; - - /** is it case sensitive. */ - public final boolean caseSensitive; - - /** can you use "WHERE" based on this type */ - public final Searchable searchable; - - /** is it unsigned. */ - public final boolean unsignedAttribute; - - /** can it be a money value. */ - public final boolean fixedPrecScale; - - /** can it be used for an auto-increment value. */ - public final boolean autoIncrement; - - /** localized version of type name (may be null) */ - public final String localTypeName; - - /** minimum scale supported */ - public final short minimumScale; - - /** maximum scale supported */ - public final short maximumScale; - - /** unused */ - public final int sqlDataType; - - /** unused */ - public final int sqlDatetimeSub; - - /** usually 2 or 10 */ - public final int numPrecRadix; - - - /** - * インスタンスを生成する。 - * - * @param typeInfo {@link DatabaseMetaData#getTypeInfo()}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public TypeInfoMeta(ResultSet typeInfo) { - Validate.notNull(typeInfo); - typeName = ResultSetUtil.getString(typeInfo, "TYPE_NAME"); - dataType = ResultSetUtil.getInt(typeInfo, "DATA_TYPE"); - precision = ResultSetUtil.getInt(typeInfo, "PRECISION"); - literalPrefix = ResultSetUtil.getString(typeInfo, "LITERAL_PREFIX"); - literalSuffix = ResultSetUtil.getString(typeInfo, "LITERAL_SUFFIX"); - createParams = ResultSetUtil.getString(typeInfo, "CREATE_PARAMS"); - nullable = Nullable.getNullable(ResultSetUtil.getShort(typeInfo, "NULLABLE")); - caseSensitive = ResultSetUtil.getBoolean(typeInfo, "CASE_SENSITIVE"); - searchable = Searchable.getSearchable(ResultSetUtil.getShort(typeInfo, "SEARCHABLE")); - unsignedAttribute = ResultSetUtil.getBoolean(typeInfo, "UNSIGNED_ATTRIBUTE"); - fixedPrecScale = ResultSetUtil.getBoolean(typeInfo, "FIXED_PREC_SCALE"); - autoIncrement = ResultSetUtil.getBoolean(typeInfo, "AUTO_INCREMENT"); - localTypeName = ResultSetUtil.getString(typeInfo, "LOCAL_TYPE_NAME"); - minimumScale = ResultSetUtil.getShort(typeInfo, "MINIMUM_SCALE"); - maximumScale = ResultSetUtil.getShort(typeInfo, "MAXIMUM_SCALE"); - sqlDataType = ResultSetUtil.getInt(typeInfo, "SQL_DATA_TYPE"); - sqlDatetimeSub = ResultSetUtil.getInt(typeInfo, "SQL_DATETIME_SUB"); - numPrecRadix = ResultSetUtil.getInt(typeInfo, "NUM_PREC_RADIX"); - - assert typeName != null; - assert nullable != null; - assert searchable != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - - /** - * データ型に対してNULLを設定可能かどうかを表す列挙型。 - * @author daisuke - */ - public static enum Nullable { - - /** does not allow NULL values */ - NO_NULLS(DatabaseMetaData.typeNoNulls), - - /** allows NULL values */ - NULLABLE(DatabaseMetaData.typeNullable), - - /** nullability unknown */ - UNKNOWN(DatabaseMetaData.typeNullableUnknown); - - /** - * {@link Nullable}の値を取得する。 - * @param value {@link DatabaseMetaData}から取得される値 - * @return {@link Nullable} - */ - private static Nullable getNullable(short value) { - for (Nullable nullable : Nullable.values()) { - if (nullable.value == value) { - return nullable; - } - } - return null; - } - - - private final int value; - - - Nullable(int value) { - this.value = value; - } - } - - /** - * can you use "WHERE" based on this type. - * - * <p>THINK 何のこっちゃ。</p> - * - * @author daisuke - */ - public static enum Searchable { - - /** No support */ - NONE(DatabaseMetaData.typePredNone), - - /** Only supported with WHERE .. LIKE */ - CHAR(DatabaseMetaData.typePredChar), - - /** Supported except for WHERE .. LIKE */ - BASIC(DatabaseMetaData.typePredBasic), - - /** Supported for all WHERE .. */ - SEARCHABLE(DatabaseMetaData.typeSearchable); - - /** - * {@link Searchable}の値を取得する。 - * @param value {@link DatabaseMetaData}から取得される値 - * @return {@link Searchable} - */ - private static Searchable getSearchable(short value) { - for (Searchable searchable : Searchable.values()) { - if (searchable.value == value) { - return searchable; - } - } - return null; - } - - - private int value; - - - Searchable(int value) { - this.value = value; - } - - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/25 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * DBから読み出したデータ型情報の保持クラス。 + * + * <p>{@link DatabaseMetaData#getTypeInfo()}の結果の一つを表す値クラス。</p> + * + * @author daisuke + */ +public class TypeInfoMeta { + + /** Type name */ + public final String typeName; + + /** SQL data type from java.sql.Types */ + public final int dataType; + + /** maximum precision */ + public final int precision; + + /** prefix used to quote a literal (may be null) */ + public final String literalPrefix; + + /** suffix used to quote a literal (may be null) */ + public final String literalSuffix; + + /** parameters used in creating the type (may be null) */ + public final String createParams; + + /** can you use NULL for this type. */ + public final Nullable nullable; + + /** is it case sensitive. */ + public final boolean caseSensitive; + + /** can you use "WHERE" based on this type */ + public final Searchable searchable; + + /** is it unsigned. */ + public final boolean unsignedAttribute; + + /** can it be a money value. */ + public final boolean fixedPrecScale; + + /** can it be used for an auto-increment value. */ + public final boolean autoIncrement; + + /** localized version of type name (may be null) */ + public final String localTypeName; + + /** minimum scale supported */ + public final short minimumScale; + + /** maximum scale supported */ + public final short maximumScale; + + /** unused */ + public final int sqlDataType; + + /** unused */ + public final int sqlDatetimeSub; + + /** usually 2 or 10 */ + public final int numPrecRadix; + + + /** + * インスタンスを生成する。 + * + * @param typeInfo {@link DatabaseMetaData#getTypeInfo()}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public TypeInfoMeta(ResultSet typeInfo) { + Validate.notNull(typeInfo); + typeName = ResultSetUtil.getString(typeInfo, "TYPE_NAME"); + dataType = ResultSetUtil.getInt(typeInfo, "DATA_TYPE"); + precision = ResultSetUtil.getInt(typeInfo, "PRECISION"); + literalPrefix = ResultSetUtil.getString(typeInfo, "LITERAL_PREFIX"); + literalSuffix = ResultSetUtil.getString(typeInfo, "LITERAL_SUFFIX"); + createParams = ResultSetUtil.getString(typeInfo, "CREATE_PARAMS"); + nullable = Nullable.getNullable(ResultSetUtil.getShort(typeInfo, "NULLABLE")); + caseSensitive = ResultSetUtil.getBoolean(typeInfo, "CASE_SENSITIVE"); + searchable = Searchable.getSearchable(ResultSetUtil.getShort(typeInfo, "SEARCHABLE")); + unsignedAttribute = ResultSetUtil.getBoolean(typeInfo, "UNSIGNED_ATTRIBUTE"); + fixedPrecScale = ResultSetUtil.getBoolean(typeInfo, "FIXED_PREC_SCALE"); + autoIncrement = ResultSetUtil.getBoolean(typeInfo, "AUTO_INCREMENT"); + localTypeName = ResultSetUtil.getString(typeInfo, "LOCAL_TYPE_NAME"); + minimumScale = ResultSetUtil.getShort(typeInfo, "MINIMUM_SCALE"); + maximumScale = ResultSetUtil.getShort(typeInfo, "MAXIMUM_SCALE"); + sqlDataType = ResultSetUtil.getInt(typeInfo, "SQL_DATA_TYPE"); + sqlDatetimeSub = ResultSetUtil.getInt(typeInfo, "SQL_DATETIME_SUB"); + numPrecRadix = ResultSetUtil.getInt(typeInfo, "NUM_PREC_RADIX"); + + assert typeName != null; + assert nullable != null; + assert searchable != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + + + /** + * データ型に対してNULLを設定可能かどうかを表す列挙型。 + * @author daisuke + */ + public static enum Nullable { + + /** does not allow NULL values */ + NO_NULLS(DatabaseMetaData.typeNoNulls), + + /** allows NULL values */ + NULLABLE(DatabaseMetaData.typeNullable), + + /** nullability unknown */ + UNKNOWN(DatabaseMetaData.typeNullableUnknown); + + /** + * {@link Nullable}の値を取得する。 + * @param value {@link DatabaseMetaData}から取得される値 + * @return {@link Nullable} + */ + private static Nullable getNullable(short value) { + for (Nullable nullable : Nullable.values()) { + if (nullable.value == value) { + return nullable; + } + } + return null; + } + + + private final int value; + + + Nullable(int value) { + this.value = value; + } + } + + /** + * can you use "WHERE" based on this type. + * + * <p>THINK 何のこっちゃ。</p> + * + * @author daisuke + */ + public static enum Searchable { + + /** No support */ + NONE(DatabaseMetaData.typePredNone), + + /** Only supported with WHERE .. LIKE */ + CHAR(DatabaseMetaData.typePredChar), + + /** Supported except for WHERE .. LIKE */ + BASIC(DatabaseMetaData.typePredBasic), + + /** Supported for all WHERE .. */ + SEARCHABLE(DatabaseMetaData.typeSearchable); + + /** + * {@link Searchable}の値を取得する。 + * @param value {@link DatabaseMetaData}から取得される値 + * @return {@link Searchable} + */ + private static Searchable getSearchable(short value) { + for (Searchable searchable : Searchable.values()) { + if (searchable.value == value) { + return searchable; + } + } + return null; + } + + + private int value; + + + Searchable(int value) { + this.value = value; + } + + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TypeInfoMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TypeSafeDatabaseMetaData.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TypeSafeDatabaseMetaData.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TypeSafeDatabaseMetaData.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,464 +1,464 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/23 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Iterator; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.exception.JiemamyError; - -/** - * {@link DatabaseMetaData}の情報をタイプセーフに取り扱うためのラッパークラス。 - * - * @author daisuke - */ -public class TypeSafeDatabaseMetaData { - - private DatabaseMetaData meta; - - - /** - * インスタンスを生成する。 - * - * @param connection 取り扱うDBへのコネクション - * @throws SQLException SQLの実行に失敗した場合 - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public TypeSafeDatabaseMetaData(Connection connection) throws SQLException { - Validate.notNull(connection); - meta = connection.getMetaData(); - } - - /** - * インスタンスを生成する。 - * - * @param meta 取り扱う{@link DatabaseMetaData} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public TypeSafeDatabaseMetaData(DatabaseMetaData meta) { - Validate.notNull(meta); - this.meta = meta; - } - - /** - * 指定されたスキーマおよびカタログで使用可能なユーザ定義の型 (UDT) のための指定された型の指定された属性に関する記述を取得する。 - * - * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schemaPattern スキーマ名パターン。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param typeNamePattern 型名パターン。データベースに格納された型名と一致しなければならない - * @param attributeNamePattern 属性名パターン。データベースで宣言された属性名と一致しなければならない - * @return 属性情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<AttributesMeta> getAttributes(String catalog, String schemaPattern, - String typeNamePattern, String attributeNamePattern) throws SQLException { - ResultSet attributes = meta.getAttributes(catalog, schemaPattern, typeNamePattern, attributeNamePattern); - return new TypeSafeResultSet<AttributesMeta>(attributes, AttributesMeta.class); - } - - /** - * 行を一意に識別するテーブルの最適な列セットに関する記述を取得する。 - * - * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param table テーブル名。データベースに格納されたテーブル名と一致しなければならない - * @param scope 対象のスケール。SCOPE と同じ値を使用する - * @param nullable null 値を許す列を含む - * @return 識別子情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<BestRowIdentifierMeta> getBestRowIdentifier(String catalog, String schema, String table, - int scope, boolean nullable) throws SQLException { - ResultSet bestRowIdentifier = meta.getBestRowIdentifier(catalog, schema, table, scope, nullable); - return new TypeSafeResultSet<BestRowIdentifierMeta>(bestRowIdentifier, BestRowIdentifierMeta.class); - } - - /** - * このデータベースで使用可能なカタログ名を取得する。 - * - * @return カタログ名情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<CatalogMeta> getCatalogs() throws SQLException { - ResultSet catalogs = meta.getCatalogs(); - return new TypeSafeResultSet<CatalogMeta>(catalogs, CatalogMeta.class); - } - - /** - * テーブルの列へのアクセス権に関する記述を取得する。 - * - * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param table テーブル名。データベースに格納されたテーブル名と一致しなければならない - * @param columnNamePattern 列名パターン。データベースに格納された列名と一致しなければならない - * @return アクセス権情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<ColumnPrivilegeMeta> getColumnPrivileges(String catalog, String schema, String table, - String columnNamePattern) throws SQLException { - ResultSet columnPrivileges = meta.getColumnPrivileges(catalog, schema, table, columnNamePattern); - return new TypeSafeResultSet<ColumnPrivilegeMeta>(columnPrivileges, ColumnPrivilegeMeta.class); - } - - /** - * 指定されたカタログで使用可能なテーブル列の記述を取得する。 - * - * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schemaPattern スキーマ名パターン。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param tableNamePattern テーブル名パターン。データベースに格納されたテーブル名と一致しなければならない - * @param columnNamePattern 列名パターン。データベースに格納された列名と一致しなければならない - * @return カラム情報 - * @throws SQLException SQLの実行に失敗した場合 - * @see DatabaseMetaData#getColumns(String, String, String, String) - */ - public TypeSafeResultSet<ColumnMeta> getColumns(String catalog, String schemaPattern, String tableNamePattern, - String columnNamePattern) throws SQLException { - ResultSet tables = meta.getColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern); - return new TypeSafeResultSet<ColumnMeta>(tables, ColumnMeta.class); - } - - /** - * 主キーテーブルの主キー列を参照する外部のキーテーブル中の、外部のキー列に関する記述 - * (テーブルが別のキーをインポートする方法を記述)を取得する。 - * - * @param primaryCatalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、選択条件からカタログ名を除外することを意味する - * @param primarySchema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、選択条件からスキーマ名を除外することを意味する - * @param primaryTable キーをエクスポートするテーブル名。データベースに格納されたテーブル名と一致しなければならない - * @param foreignCatalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、選択条件からカタログ名を除外することを意味する - * @param foreignSchema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、選択条件からスキーマ名を除外することを意味する - * @param foreignTable キーをインポートするテーブル名。データベースに格納されたテーブル名と一致しなければならない - * @return キー情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<KeyMeta> getCrossReference(String primaryCatalog, String primarySchema, - String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException { - ResultSet crossReference = - meta.getCrossReference(primaryCatalog, primarySchema, primaryTable, foreignCatalog, foreignSchema, - foreignTable); - return new TypeSafeResultSet<KeyMeta>(crossReference, KeyMeta.class); - } - - /** - * テーブルの主キー列 (テーブルによってエクスポートされた外部キー) を参照する外部キー列に関する記述を取得する。 - * - * @param catalog -カタログ名。このデータベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param table テーブル名。このデータベースに格納されたテーブル名と一致しなければならない - * @return キー情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<KeyMeta> getExportedKeys(String catalog, String schema, String table) throws SQLException { - ResultSet exportedKeys = meta.getExportedKeys(catalog, schema, table); - return new TypeSafeResultSet<KeyMeta>(exportedKeys, KeyMeta.class); - } - - /** - * テーブルの外部キー列 (テーブルによってインポートされる主キー) を参照する主キー列に関する記述を取得する。 - * - * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param table テーブル名。データベースに格納されたテーブル名と一致しなければならない - * @return キー情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<KeyMeta> getImportedKeys(String catalog, String schema, String table) throws SQLException { - ResultSet importedKeys = meta.getImportedKeys(catalog, schema, table); - return new TypeSafeResultSet<KeyMeta>(importedKeys, KeyMeta.class); - } - - /** - * テーブルのインデックスと統計情報に関する記述を取得する。 - * - * @param catalog カタログ名。このデータベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schema スキーマ名。このデータベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param table テーブル名。このデータベースに格納されたテーブル名と一致しなければならない - * @param unique true の場合は、一意の値のインデックスだけを返す。false の場合は、一意であるかどうかにかかわらずインデックスを返す - * @param approximate true の場合は、結果は概数またはデータ値から外れることもある。false の場合は、正確であることが要求される - * @return インデックス情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<IndexInfoMeta> getIndexInfo(String catalog, String schema, String table, boolean unique, - boolean approximate) throws SQLException { - ResultSet indexInfo = meta.getIndexInfo(catalog, schema, table, unique, approximate); - return new TypeSafeResultSet<IndexInfoMeta>(indexInfo, IndexInfoMeta.class); - } - - /** - * テーブルの主キー列の記述を取得する。 - * - * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param table テーブル名。データベースに格納されたテーブル名と一致しなければならない - * @return キー情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<PrimaryKeyMeta> getPrimaryKeys(String catalog, String schema, String table) - throws SQLException { - ResultSet primaryKeys = meta.getPrimaryKeys(catalog, schema, table); - return new TypeSafeResultSet<PrimaryKeyMeta>(primaryKeys, PrimaryKeyMeta.class); - } - - /** - * カタログのストアドプロシージャパラメータと結果列に関する記述を取得する。 - * - * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schemaPattern スキーマ名パターン。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param procedureNamePattern プロシージャ名パターン。データベースに格納されたプロシージャ名と一致しなければならない - * @param columnNamePattern 列名パターン。データベースに格納された列名と一致しなければならない - * @return ストアドプロシージャ情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<ProcedureColumnsMeta> getProcedureColumns(String catalog, String schemaPattern, - String procedureNamePattern, String columnNamePattern) throws SQLException { - ResultSet procedureColumns = - meta.getProcedureColumns(catalog, schemaPattern, procedureNamePattern, columnNamePattern); - return new TypeSafeResultSet<ProcedureColumnsMeta>(procedureColumns, ProcedureColumnsMeta.class); - } - - /** - * カタログで使用可能なストアドプロシージャに関する記述を取得する。 - * - * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schemaPattern スキーマ名パターン。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param procedureNamePattern プロシージャ名パターン。データベースに格納されたプロシージャ名と一致しなければならない - * @return ストアドプロシージャ情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<ProcedureMeta> getProcedures(String catalog, String schemaPattern, - String procedureNamePattern) throws SQLException { - ResultSet procedures = meta.getProcedures(catalog, schemaPattern, procedureNamePattern); - return new TypeSafeResultSet<ProcedureMeta>(procedures, ProcedureMeta.class); - } - - /** - * このデータベースで使用可能なスキーマ名を取得する。 - * - * @return スキーマ名情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<SchemaMeta> getSchemas() throws SQLException { - ResultSet schemas = meta.getSchemas(); - return new TypeSafeResultSet<SchemaMeta>(schemas, SchemaMeta.class); - } - - /** - * このデータベースの特定のスキーマで定義されているテーブル階層の説明を取得する。 - * - * @param catalog カタログ名。"" はカタログなしでカタログ名を検索する。null は、選択条件からカタログ名を除外することを意味する - * @param schemaPattern スキーマ名パターン。"" はスキーマなしでスキーマ名を検索する - * @param tableNamePattern テーブル名パターン。完全指定名の可能性がある - * @return テーブル階層情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<SuperTableMeta> getSuperTables(String catalog, String schemaPattern, - String tableNamePattern) throws SQLException { - ResultSet superTables = meta.getSuperTables(catalog, schemaPattern, tableNamePattern); - return new TypeSafeResultSet<SuperTableMeta>(superTables, SuperTableMeta.class); - } - - /** - * このデータベースの特定のスキーマで定義されているユーザ定義型 (UDT) 階層の説明を取得する。 - * - * @param catalog カタログ名。"" はカタログなしでカタログ名を検索する。null は、選択条件からカタログ名を除外することを意味する - * @param schemaPattern スキーマ名パターン。"" はスキーマなしでスキーマ名を検索する - * @param typeNamePattern UDT 名パターン。完全指定名の可能性がある - * @return UDT階層情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<SuperTypeMeta> getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) - throws SQLException { - ResultSet superTypes = meta.getSuperTypes(catalog, schemaPattern, typeNamePattern); - return new TypeSafeResultSet<SuperTypeMeta>(superTypes, SuperTypeMeta.class); - } - - /** - * カタログで使用可能な各テーブルに対するアクセス権に関する記述を取得する。 - * - * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schemaPattern スキーマ名パターン。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param tableNamePattern テーブル名パターン。データベースに格納されたテーブル名と一致しなければならない - * @return アクセス権情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<TablePrivilegeMeta> getTablePrivileges(String catalog, String schemaPattern, - String tableNamePattern) throws SQLException { - ResultSet tablePrivileges = meta.getTablePrivileges(catalog, schemaPattern, tableNamePattern); - return new TypeSafeResultSet<TablePrivilegeMeta>(tablePrivileges, TablePrivilegeMeta.class); - } - - /** - * カタログで使用可能なテーブルに関する記述を取得する。 - * - * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schemaPattern スキーマ名パターン。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param tableNamePattern テーブル名パターン。データベースに格納されたテーブル名と一致しなければならない - * @param types 組み込むテーブルの型のリスト。null はすべての型を返す - * @return テーブル情報 - * @throws SQLException SQLの実行に失敗した場合 - * @see DatabaseMetaData#getTables(String, String, String, String[]) - */ - public TypeSafeResultSet<TableMeta> getTables(String catalog, String schemaPattern, String tableNamePattern, - String[] types) throws SQLException { - ResultSet tables = meta.getTables(catalog, schemaPattern, tableNamePattern, types); - return new TypeSafeResultSet<TableMeta>(tables, TableMeta.class); - } - - /** - * このデータベースで使用可能なテーブルタイプを取得する。 - * - * @return テーブルタイプ情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<TableTypeMeta> getTableTypes() throws SQLException { - ResultSet tableTypes = meta.getTableTypes(); - return new TypeSafeResultSet<TableTypeMeta>(tableTypes, TableTypeMeta.class); - } - - /** - * このデータベースでサポートされているすべての標準 SQL タイプに関する記述を取得する。 - * - * @return データ型情報 - * @throws SQLException SQLの実行に失敗した場合 - * @see DatabaseMetaData#getTypeInfo() - */ - public TypeSafeResultSet<TypeInfoMeta> getTypeInfo() throws SQLException { - ResultSet typeInfo = meta.getTypeInfo(); - return new TypeSafeResultSet<TypeInfoMeta>(typeInfo, TypeInfoMeta.class); - } - - /** - * 特定のスキーマで定義されているユーザ定義型の説明を取得する。 - * - * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schemaPattern スキーマパターン名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param typeNamePattern 型名パターン。データベースに格納された型名と一致しなければならない。完全指定名の可能性がある - * @param types ユーザ定義型のリスト (JAVA_OBJECT、STRUCT、または DISTINCT を含む)。null の場合はすべての型を返す - * @return ユーザ定義型情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<UDTMeta> getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) - throws SQLException { - ResultSet udts = meta.getUDTs(catalog, schemaPattern, typeNamePattern, types); - return new TypeSafeResultSet<UDTMeta>(udts, UDTMeta.class); - } - - /** - * 行の任意の値が変更された場合に、自動的に更新されるテーブルの列に関する記述を取得する。 - * - * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する - * @param schema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する - * @param table テーブル名。データベースに格納されたテーブル名と一致しなければならない - * @return バージョンカラム情報 - * @throws SQLException SQLの実行に失敗した場合 - */ - public TypeSafeResultSet<VersionColumnMeta> getVersionColumns(String catalog, String schema, String table) - throws SQLException { - ResultSet versionColumns = meta.getVersionColumns(catalog, schema, table); - return new TypeSafeResultSet<VersionColumnMeta>(versionColumns, VersionColumnMeta.class); - } - - - /** - * {@link ResultSet}の{@link Iterator}を取得できる{@link Iterable}の実装クラス。 - * - * @param <T> イテレートする型 - * @author daisuke - */ - public static class TypeSafeResultSet<T> { - - private ResultSet resultSet; - - private Class<T> resultClass; - - - TypeSafeResultSet(ResultSet resultSet, Class<T> resultClass) { - Validate.notNull(resultSet); - Validate.notNull(resultClass); - this.resultSet = resultSet; - this.resultClass = resultClass; - } - - /** - * Releases this <code>ResultSet</code> object's database and - * JDBC resources immediately instead of waiting for - * this to happen when it is automatically closed. - * - * @throws SQLException if a database access error occurs - */ - public void close() throws SQLException { - resultSet.close(); - } - - /** - * 現在のカーソル位置の結果を取得する。 - * - * @return 現在のカーソル位置の結果 - * @throws SQLException SQLの実行に失敗した場合。 - */ - public T getResult() throws SQLException { - try { - Constructor<T> constructor = resultClass.getConstructor(ResultSet.class); - return constructor.newInstance(resultSet); - } catch (SecurityException e) { - throw new JiemamyError("unknown", e); - } catch (NoSuchMethodException e) { - throw new JiemamyError("resultClass must have ResultSet constructor.", e); - } catch (IllegalArgumentException e) { - throw new JiemamyError("Coding miss.", e); - } catch (InstantiationException e) { - throw new JiemamyError("resultClass must not be abstract class.", e); - } catch (IllegalAccessException e) { - throw new JiemamyError("resultClass must have public constructor.", e); - } catch (InvocationTargetException e) { - Throwable cause = e.getCause(); - if (cause instanceof SQLException) { - throw (SQLException) cause; - } - throw new JiemamyError("resultClass construction failed.", e); - } - } - - /** - * Moves the cursor down one row from its current position. - * A <code>ResultSet</code> cursor is initially positioned - * before the first row; the first call to the method - * <code>next</code> makes the first row the current row; the - * second call makes the second row the current row, and so on. - * - * <P>If an input stream is open for the current row, a call - * to the method <code>next</code> will - * implicitly close it. A <code>ResultSet</code> object's - * warning chain is cleared when a new row is read. - * - * @return <code>true</code> if the new current row is valid; - * <code>false</code> if there are no more rows - * @exception SQLException if a database access error occurs - */ - public boolean next() throws SQLException { - return resultSet.next(); - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/23 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Iterator; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.exception.JiemamyError; + +/** + * {@link DatabaseMetaData}の情報をタイプセーフに取り扱うためのラッパークラス。 + * + * @author daisuke + */ +public class TypeSafeDatabaseMetaData { + + private DatabaseMetaData meta; + + + /** + * インスタンスを生成する。 + * + * @param connection 取り扱うDBへのコネクション + * @throws SQLException SQLの実行に失敗した場合 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public TypeSafeDatabaseMetaData(Connection connection) throws SQLException { + Validate.notNull(connection); + meta = connection.getMetaData(); + } + + /** + * インスタンスを生成する。 + * + * @param meta 取り扱う{@link DatabaseMetaData} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public TypeSafeDatabaseMetaData(DatabaseMetaData meta) { + Validate.notNull(meta); + this.meta = meta; + } + + /** + * 指定されたスキーマおよびカタログで使用可能なユーザ定義の型 (UDT) のための指定された型の指定された属性に関する記述を取得する。 + * + * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schemaPattern スキーマ名パターン。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param typeNamePattern 型名パターン。データベースに格納された型名と一致しなければならない + * @param attributeNamePattern 属性名パターン。データベースで宣言された属性名と一致しなければならない + * @return 属性情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<AttributesMeta> getAttributes(String catalog, String schemaPattern, + String typeNamePattern, String attributeNamePattern) throws SQLException { + ResultSet attributes = meta.getAttributes(catalog, schemaPattern, typeNamePattern, attributeNamePattern); + return new TypeSafeResultSet<AttributesMeta>(attributes, AttributesMeta.class); + } + + /** + * 行を一意に識別するテーブルの最適な列セットに関する記述を取得する。 + * + * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param table テーブル名。データベースに格納されたテーブル名と一致しなければならない + * @param scope 対象のスケール。SCOPE と同じ値を使用する + * @param nullable null 値を許す列を含む + * @return 識別子情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<BestRowIdentifierMeta> getBestRowIdentifier(String catalog, String schema, String table, + int scope, boolean nullable) throws SQLException { + ResultSet bestRowIdentifier = meta.getBestRowIdentifier(catalog, schema, table, scope, nullable); + return new TypeSafeResultSet<BestRowIdentifierMeta>(bestRowIdentifier, BestRowIdentifierMeta.class); + } + + /** + * このデータベースで使用可能なカタログ名を取得する。 + * + * @return カタログ名情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<CatalogMeta> getCatalogs() throws SQLException { + ResultSet catalogs = meta.getCatalogs(); + return new TypeSafeResultSet<CatalogMeta>(catalogs, CatalogMeta.class); + } + + /** + * テーブルの列へのアクセス権に関する記述を取得する。 + * + * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param table テーブル名。データベースに格納されたテーブル名と一致しなければならない + * @param columnNamePattern 列名パターン。データベースに格納された列名と一致しなければならない + * @return アクセス権情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<ColumnPrivilegeMeta> getColumnPrivileges(String catalog, String schema, String table, + String columnNamePattern) throws SQLException { + ResultSet columnPrivileges = meta.getColumnPrivileges(catalog, schema, table, columnNamePattern); + return new TypeSafeResultSet<ColumnPrivilegeMeta>(columnPrivileges, ColumnPrivilegeMeta.class); + } + + /** + * 指定されたカタログで使用可能なテーブル列の記述を取得する。 + * + * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schemaPattern スキーマ名パターン。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param tableNamePattern テーブル名パターン。データベースに格納されたテーブル名と一致しなければならない + * @param columnNamePattern 列名パターン。データベースに格納された列名と一致しなければならない + * @return カラム情報 + * @throws SQLException SQLの実行に失敗した場合 + * @see DatabaseMetaData#getColumns(String, String, String, String) + */ + public TypeSafeResultSet<ColumnMeta> getColumns(String catalog, String schemaPattern, String tableNamePattern, + String columnNamePattern) throws SQLException { + ResultSet tables = meta.getColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern); + return new TypeSafeResultSet<ColumnMeta>(tables, ColumnMeta.class); + } + + /** + * 主キーテーブルの主キー列を参照する外部のキーテーブル中の、外部のキー列に関する記述 + * (テーブルが別のキーをインポートする方法を記述)を取得する。 + * + * @param primaryCatalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、選択条件からカタログ名を除外することを意味する + * @param primarySchema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、選択条件からスキーマ名を除外することを意味する + * @param primaryTable キーをエクスポートするテーブル名。データベースに格納されたテーブル名と一致しなければならない + * @param foreignCatalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、選択条件からカタログ名を除外することを意味する + * @param foreignSchema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、選択条件からスキーマ名を除外することを意味する + * @param foreignTable キーをインポートするテーブル名。データベースに格納されたテーブル名と一致しなければならない + * @return キー情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<KeyMeta> getCrossReference(String primaryCatalog, String primarySchema, + String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException { + ResultSet crossReference = + meta.getCrossReference(primaryCatalog, primarySchema, primaryTable, foreignCatalog, foreignSchema, + foreignTable); + return new TypeSafeResultSet<KeyMeta>(crossReference, KeyMeta.class); + } + + /** + * テーブルの主キー列 (テーブルによってエクスポートされた外部キー) を参照する外部キー列に関する記述を取得する。 + * + * @param catalog -カタログ名。このデータベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param table テーブル名。このデータベースに格納されたテーブル名と一致しなければならない + * @return キー情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<KeyMeta> getExportedKeys(String catalog, String schema, String table) throws SQLException { + ResultSet exportedKeys = meta.getExportedKeys(catalog, schema, table); + return new TypeSafeResultSet<KeyMeta>(exportedKeys, KeyMeta.class); + } + + /** + * テーブルの外部キー列 (テーブルによってインポートされる主キー) を参照する主キー列に関する記述を取得する。 + * + * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param table テーブル名。データベースに格納されたテーブル名と一致しなければならない + * @return キー情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<KeyMeta> getImportedKeys(String catalog, String schema, String table) throws SQLException { + ResultSet importedKeys = meta.getImportedKeys(catalog, schema, table); + return new TypeSafeResultSet<KeyMeta>(importedKeys, KeyMeta.class); + } + + /** + * テーブルのインデックスと統計情報に関する記述を取得する。 + * + * @param catalog カタログ名。このデータベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schema スキーマ名。このデータベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param table テーブル名。このデータベースに格納されたテーブル名と一致しなければならない + * @param unique true の場合は、一意の値のインデックスだけを返す。false の場合は、一意であるかどうかにかかわらずインデックスを返す + * @param approximate true の場合は、結果は概数またはデータ値から外れることもある。false の場合は、正確であることが要求される + * @return インデックス情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<IndexInfoMeta> getIndexInfo(String catalog, String schema, String table, boolean unique, + boolean approximate) throws SQLException { + ResultSet indexInfo = meta.getIndexInfo(catalog, schema, table, unique, approximate); + return new TypeSafeResultSet<IndexInfoMeta>(indexInfo, IndexInfoMeta.class); + } + + /** + * テーブルの主キー列の記述を取得する。 + * + * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param table テーブル名。データベースに格納されたテーブル名と一致しなければならない + * @return キー情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<PrimaryKeyMeta> getPrimaryKeys(String catalog, String schema, String table) + throws SQLException { + ResultSet primaryKeys = meta.getPrimaryKeys(catalog, schema, table); + return new TypeSafeResultSet<PrimaryKeyMeta>(primaryKeys, PrimaryKeyMeta.class); + } + + /** + * カタログのストアドプロシージャパラメータと結果列に関する記述を取得する。 + * + * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schemaPattern スキーマ名パターン。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param procedureNamePattern プロシージャ名パターン。データベースに格納されたプロシージャ名と一致しなければならない + * @param columnNamePattern 列名パターン。データベースに格納された列名と一致しなければならない + * @return ストアドプロシージャ情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<ProcedureColumnsMeta> getProcedureColumns(String catalog, String schemaPattern, + String procedureNamePattern, String columnNamePattern) throws SQLException { + ResultSet procedureColumns = + meta.getProcedureColumns(catalog, schemaPattern, procedureNamePattern, columnNamePattern); + return new TypeSafeResultSet<ProcedureColumnsMeta>(procedureColumns, ProcedureColumnsMeta.class); + } + + /** + * カタログで使用可能なストアドプロシージャに関する記述を取得する。 + * + * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schemaPattern スキーマ名パターン。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param procedureNamePattern プロシージャ名パターン。データベースに格納されたプロシージャ名と一致しなければならない + * @return ストアドプロシージャ情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<ProcedureMeta> getProcedures(String catalog, String schemaPattern, + String procedureNamePattern) throws SQLException { + ResultSet procedures = meta.getProcedures(catalog, schemaPattern, procedureNamePattern); + return new TypeSafeResultSet<ProcedureMeta>(procedures, ProcedureMeta.class); + } + + /** + * このデータベースで使用可能なスキーマ名を取得する。 + * + * @return スキーマ名情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<SchemaMeta> getSchemas() throws SQLException { + ResultSet schemas = meta.getSchemas(); + return new TypeSafeResultSet<SchemaMeta>(schemas, SchemaMeta.class); + } + + /** + * このデータベースの特定のスキーマで定義されているテーブル階層の説明を取得する。 + * + * @param catalog カタログ名。"" はカタログなしでカタログ名を検索する。null は、選択条件からカタログ名を除外することを意味する + * @param schemaPattern スキーマ名パターン。"" はスキーマなしでスキーマ名を検索する + * @param tableNamePattern テーブル名パターン。完全指定名の可能性がある + * @return テーブル階層情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<SuperTableMeta> getSuperTables(String catalog, String schemaPattern, + String tableNamePattern) throws SQLException { + ResultSet superTables = meta.getSuperTables(catalog, schemaPattern, tableNamePattern); + return new TypeSafeResultSet<SuperTableMeta>(superTables, SuperTableMeta.class); + } + + /** + * このデータベースの特定のスキーマで定義されているユーザ定義型 (UDT) 階層の説明を取得する。 + * + * @param catalog カタログ名。"" はカタログなしでカタログ名を検索する。null は、選択条件からカタログ名を除外することを意味する + * @param schemaPattern スキーマ名パターン。"" はスキーマなしでスキーマ名を検索する + * @param typeNamePattern UDT 名パターン。完全指定名の可能性がある + * @return UDT階層情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<SuperTypeMeta> getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) + throws SQLException { + ResultSet superTypes = meta.getSuperTypes(catalog, schemaPattern, typeNamePattern); + return new TypeSafeResultSet<SuperTypeMeta>(superTypes, SuperTypeMeta.class); + } + + /** + * カタログで使用可能な各テーブルに対するアクセス権に関する記述を取得する。 + * + * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schemaPattern スキーマ名パターン。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param tableNamePattern テーブル名パターン。データベースに格納されたテーブル名と一致しなければならない + * @return アクセス権情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<TablePrivilegeMeta> getTablePrivileges(String catalog, String schemaPattern, + String tableNamePattern) throws SQLException { + ResultSet tablePrivileges = meta.getTablePrivileges(catalog, schemaPattern, tableNamePattern); + return new TypeSafeResultSet<TablePrivilegeMeta>(tablePrivileges, TablePrivilegeMeta.class); + } + + /** + * カタログで使用可能なテーブルに関する記述を取得する。 + * + * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schemaPattern スキーマ名パターン。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param tableNamePattern テーブル名パターン。データベースに格納されたテーブル名と一致しなければならない + * @param types 組み込むテーブルの型のリスト。null はすべての型を返す + * @return テーブル情報 + * @throws SQLException SQLの実行に失敗した場合 + * @see DatabaseMetaData#getTables(String, String, String, String[]) + */ + public TypeSafeResultSet<TableMeta> getTables(String catalog, String schemaPattern, String tableNamePattern, + String[] types) throws SQLException { + ResultSet tables = meta.getTables(catalog, schemaPattern, tableNamePattern, types); + return new TypeSafeResultSet<TableMeta>(tables, TableMeta.class); + } + + /** + * このデータベースで使用可能なテーブルタイプを取得する。 + * + * @return テーブルタイプ情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<TableTypeMeta> getTableTypes() throws SQLException { + ResultSet tableTypes = meta.getTableTypes(); + return new TypeSafeResultSet<TableTypeMeta>(tableTypes, TableTypeMeta.class); + } + + /** + * このデータベースでサポートされているすべての標準 SQL タイプに関する記述を取得する。 + * + * @return データ型情報 + * @throws SQLException SQLの実行に失敗した場合 + * @see DatabaseMetaData#getTypeInfo() + */ + public TypeSafeResultSet<TypeInfoMeta> getTypeInfo() throws SQLException { + ResultSet typeInfo = meta.getTypeInfo(); + return new TypeSafeResultSet<TypeInfoMeta>(typeInfo, TypeInfoMeta.class); + } + + /** + * 特定のスキーマで定義されているユーザ定義型の説明を取得する。 + * + * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schemaPattern スキーマパターン名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param typeNamePattern 型名パターン。データベースに格納された型名と一致しなければならない。完全指定名の可能性がある + * @param types ユーザ定義型のリスト (JAVA_OBJECT、STRUCT、または DISTINCT を含む)。null の場合はすべての型を返す + * @return ユーザ定義型情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<UDTMeta> getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) + throws SQLException { + ResultSet udts = meta.getUDTs(catalog, schemaPattern, typeNamePattern, types); + return new TypeSafeResultSet<UDTMeta>(udts, UDTMeta.class); + } + + /** + * 行の任意の値が変更された場合に、自動的に更新されるテーブルの列に関する記述を取得する。 + * + * @param catalog カタログ名。データベースに格納されたカタログ名と一致しなければならない。"" はカタログなしでカタログ名を検索する。null は、カタログ名を検索の限定に使用してはならないことを意味する + * @param schema スキーマ名。データベースに格納されたスキーマ名と一致しなければならない。"" はスキーマなしでスキーマ名を検索する。null は、スキーマ名を検索の限定に使用してはならないことを意味する + * @param table テーブル名。データベースに格納されたテーブル名と一致しなければならない + * @return バージョンカラム情報 + * @throws SQLException SQLの実行に失敗した場合 + */ + public TypeSafeResultSet<VersionColumnMeta> getVersionColumns(String catalog, String schema, String table) + throws SQLException { + ResultSet versionColumns = meta.getVersionColumns(catalog, schema, table); + return new TypeSafeResultSet<VersionColumnMeta>(versionColumns, VersionColumnMeta.class); + } + + + /** + * {@link ResultSet}の{@link Iterator}を取得できる{@link Iterable}の実装クラス。 + * + * @param <T> イテレートする型 + * @author daisuke + */ + public static class TypeSafeResultSet<T> { + + private ResultSet resultSet; + + private Class<T> resultClass; + + + TypeSafeResultSet(ResultSet resultSet, Class<T> resultClass) { + Validate.notNull(resultSet); + Validate.notNull(resultClass); + this.resultSet = resultSet; + this.resultClass = resultClass; + } + + /** + * Releases this <code>ResultSet</code> object's database and + * JDBC resources immediately instead of waiting for + * this to happen when it is automatically closed. + * + * @throws SQLException if a database access error occurs + */ + public void close() throws SQLException { + resultSet.close(); + } + + /** + * 現在のカーソル位置の結果を取得する。 + * + * @return 現在のカーソル位置の結果 + * @throws SQLException SQLの実行に失敗した場合。 + */ + public T getResult() throws SQLException { + try { + Constructor<T> constructor = resultClass.getConstructor(ResultSet.class); + return constructor.newInstance(resultSet); + } catch (SecurityException e) { + throw new JiemamyError("unknown", e); + } catch (NoSuchMethodException e) { + throw new JiemamyError("resultClass must have ResultSet constructor.", e); + } catch (IllegalArgumentException e) { + throw new JiemamyError("Coding miss.", e); + } catch (InstantiationException e) { + throw new JiemamyError("resultClass must not be abstract class.", e); + } catch (IllegalAccessException e) { + throw new JiemamyError("resultClass must have public constructor.", e); + } catch (InvocationTargetException e) { + Throwable cause = e.getCause(); + if (cause instanceof SQLException) { + throw (SQLException) cause; + } + throw new JiemamyError("resultClass construction failed.", e); + } + } + + /** + * Moves the cursor down one row from its current position. + * A <code>ResultSet</code> cursor is initially positioned + * before the first row; the first call to the method + * <code>next</code> makes the first row the current row; the + * second call makes the second row the current row, and so on. + * + * <P>If an input stream is open for the current row, a call + * to the method <code>next</code> will + * implicitly close it. A <code>ResultSet</code> object's + * warning chain is cleared when a new row is read. + * + * @return <code>true</code> if the new current row is valid; + * <code>false</code> if there are no more rows + * @exception SQLException if a database access error occurs + */ + public boolean next() throws SQLException { + return resultSet.next(); + } + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/TypeSafeDatabaseMetaData.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/UDTMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/UDTMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/UDTMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,88 +1,88 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getUDTs(String, String, String, int[])}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class UDTMeta { - - /** the type's catalog (may be null) */ - public final String typeCat; - - /** type's schema (may be null) */ - public final String typeSchem; - - /** type name */ - public final String typeName; - - /** Java class name */ - public final String className; - - /** type value defined in java.sql.Types. One of JAVA_OBJECT, STRUCT, or DISTINCT */ - public final int dataType; - - /** explanatory comment on the type */ - public final String remarks; - - /** - * type code of the source type of a DISTINCT type or the type that implements the user-generated reference type - * of the SELF_REFERENCING_COLUMN of a structured type as defined in java.sql.Types (null if DATA_TYPE is - * not DISTINCT or not STRUCT with REFERENCE_GENERATION = USER_DEFINED) - */ - public final short baseType; - - - /** - * インスタンスを生成する。 - * - * @param udt {@link DatabaseMetaData#getUDTs(String, String, String, int[])}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public UDTMeta(ResultSet udt) { - Validate.notNull(udt); - typeCat = ResultSetUtil.getString(udt, "TYPE_CAT"); - typeSchem = ResultSetUtil.getString(udt, "TYPE_SCHEM"); - typeName = ResultSetUtil.getString(udt, "TYPE_NAME"); - className = ResultSetUtil.getString(udt, "CLASS_NAME"); - dataType = ResultSetUtil.getInt(udt, "DATA_TYPE"); - remarks = ResultSetUtil.getString(udt, "REMARKS"); - baseType = ResultSetUtil.getShort(udt, "BASE_TYPE"); - - assert typeName != null; - assert className != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getUDTs(String, String, String, int[])}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class UDTMeta { + + /** the type's catalog (may be null) */ + public final String typeCat; + + /** type's schema (may be null) */ + public final String typeSchem; + + /** type name */ + public final String typeName; + + /** Java class name */ + public final String className; + + /** type value defined in java.sql.Types. One of JAVA_OBJECT, STRUCT, or DISTINCT */ + public final int dataType; + + /** explanatory comment on the type */ + public final String remarks; + + /** + * type code of the source type of a DISTINCT type or the type that implements the user-generated reference type + * of the SELF_REFERENCING_COLUMN of a structured type as defined in java.sql.Types (null if DATA_TYPE is + * not DISTINCT or not STRUCT with REFERENCE_GENERATION = USER_DEFINED) + */ + public final short baseType; + + + /** + * インスタンスを生成する。 + * + * @param udt {@link DatabaseMetaData#getUDTs(String, String, String, int[])}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public UDTMeta(ResultSet udt) { + Validate.notNull(udt); + typeCat = ResultSetUtil.getString(udt, "TYPE_CAT"); + typeSchem = ResultSetUtil.getString(udt, "TYPE_SCHEM"); + typeName = ResultSetUtil.getString(udt, "TYPE_NAME"); + className = ResultSetUtil.getString(udt, "CLASS_NAME"); + dataType = ResultSetUtil.getInt(udt, "DATA_TYPE"); + remarks = ResultSetUtil.getString(udt, "REMARKS"); + baseType = ResultSetUtil.getShort(udt, "BASE_TYPE"); + + assert typeName != null; + assert className != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/UDTMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/VersionColumnMeta.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/VersionColumnMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/VersionColumnMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,123 +1,123 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/30 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils.metadata; - -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.utils.ResultSetUtil; - -/** - * {@link DatabaseMetaData#getVersionColumns(String, String, String)}の結果の一つを表す値クラス。 - * - * @author daisuke - */ -public class VersionColumnMeta { - - /** is not used */ - public final String scope; - - /** column name */ - public final String columnName; - - /** SQL data type from java.sql.Types */ - public final int dataType; - - /** Data source-dependent type name */ - public final String typeName; - - /** precision */ - public final int columnSize; - - /** length of column value in bytes */ - public final int bufferLength; - - /** scale */ - public final short decimalDigits; - - /** whether this is pseudo column like an Oracle ROWID */ - public final PseudoColumn pseudoColumn; - - - /** - * インスタンスを生成する。 - * - * @param versionColumn {@link DatabaseMetaData#getVersionColumns(String, String, String)}の結果{@link ResultSet} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public VersionColumnMeta(ResultSet versionColumn) { - Validate.notNull(versionColumn); - scope = ResultSetUtil.getString(versionColumn, "SCOPE"); - columnName = ResultSetUtil.getString(versionColumn, "COLUMN_NAME"); - dataType = ResultSetUtil.getInt(versionColumn, "DATA_TYPE"); - typeName = ResultSetUtil.getString(versionColumn, "TYPE_NAME"); - columnSize = ResultSetUtil.getInt(versionColumn, "COLUMN_SIZE"); - bufferLength = ResultSetUtil.getInt(versionColumn, "BUFFER_LENGTH"); - decimalDigits = ResultSetUtil.getShort(versionColumn, "DECIMAL_DIGITS"); - pseudoColumn = PseudoColumn.getPseudoColumn(ResultSetUtil.getShort(versionColumn, "PSEUDO_COLUMN")); - - assert scope != null; - assert columnName != null; - assert typeName != null; - assert pseudoColumn != null; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - - /** - * 疑似列であるかどうかを示す列挙型。 - * @author daisuke - */ - public static enum PseudoColumn { - - /** may or may not be pseudo column */ - UNKNOWN(DatabaseMetaData.versionColumnUnknown), - - /** is NOT a pseudo column */ - NOT_PSEUDO(DatabaseMetaData.versionColumnNotPseudo), - - /** is a pseudo column */ - PSEUDO(DatabaseMetaData.versionColumnPseudo); - - private static PseudoColumn getPseudoColumn(short value) { - for (PseudoColumn pseudoColumn : PseudoColumn.values()) { - if (pseudoColumn.value == value) { - return pseudoColumn; - } - } - return null; - } - - - private int value; - - - PseudoColumn(int value) { - this.value = value; - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/30 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils.metadata; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.utils.ResultSetUtil; + +/** + * {@link DatabaseMetaData#getVersionColumns(String, String, String)}の結果の一つを表す値クラス。 + * + * @author daisuke + */ +public class VersionColumnMeta { + + /** is not used */ + public final String scope; + + /** column name */ + public final String columnName; + + /** SQL data type from java.sql.Types */ + public final int dataType; + + /** Data source-dependent type name */ + public final String typeName; + + /** precision */ + public final int columnSize; + + /** length of column value in bytes */ + public final int bufferLength; + + /** scale */ + public final short decimalDigits; + + /** whether this is pseudo column like an Oracle ROWID */ + public final PseudoColumn pseudoColumn; + + + /** + * インスタンスを生成する。 + * + * @param versionColumn {@link DatabaseMetaData#getVersionColumns(String, String, String)}の結果{@link ResultSet} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public VersionColumnMeta(ResultSet versionColumn) { + Validate.notNull(versionColumn); + scope = ResultSetUtil.getString(versionColumn, "SCOPE"); + columnName = ResultSetUtil.getString(versionColumn, "COLUMN_NAME"); + dataType = ResultSetUtil.getInt(versionColumn, "DATA_TYPE"); + typeName = ResultSetUtil.getString(versionColumn, "TYPE_NAME"); + columnSize = ResultSetUtil.getInt(versionColumn, "COLUMN_SIZE"); + bufferLength = ResultSetUtil.getInt(versionColumn, "BUFFER_LENGTH"); + decimalDigits = ResultSetUtil.getShort(versionColumn, "DECIMAL_DIGITS"); + pseudoColumn = PseudoColumn.getPseudoColumn(ResultSetUtil.getShort(versionColumn, "PSEUDO_COLUMN")); + + assert scope != null; + assert columnName != null; + assert typeName != null; + assert pseudoColumn != null; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); + } + + + /** + * 疑似列であるかどうかを示す列挙型。 + * @author daisuke + */ + public static enum PseudoColumn { + + /** may or may not be pseudo column */ + UNKNOWN(DatabaseMetaData.versionColumnUnknown), + + /** is NOT a pseudo column */ + NOT_PSEUDO(DatabaseMetaData.versionColumnNotPseudo), + + /** is a pseudo column */ + PSEUDO(DatabaseMetaData.versionColumnPseudo); + + private static PseudoColumn getPseudoColumn(short value) { + for (PseudoColumn pseudoColumn : PseudoColumn.values()) { + if (pseudoColumn.value == value) { + return pseudoColumn; + } + } + return null; + } + + + private int value; + + + PseudoColumn(int value) { + this.value = value; + } + } +} Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/VersionColumnMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/package-info.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/package-info.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/package-info.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,9 +1,9 @@ -/** - * {@link java.sql.DatabaseMetaData}の情報をタイプセーフに取り扱うためのラッパークラス群を提供するパッケージ。 - * - * <p>現段階では実験的試みであり、使用されていない。</p> - * - * @author daisuke - */ -package org.jiemamy.utils.metadata; - +/** + * {@link java.sql.DatabaseMetaData}の情報をタイプセーフに取り扱うためのラッパークラス群を提供するパッケージ。 + * + * <p>現段階では実験的試みであり、使用されていない。</p> + * + * @author daisuke + */ +package org.jiemamy.utils.metadata; + Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/metadata/package-info.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/JmStringUtilTest.java =================================================================== --- leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/JmStringUtilTest.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/JmStringUtilTest.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,193 +1,193 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/29 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * {@link JmStringUtil}のテストクラス。 - * - * @author daisuke - */ -public class JmStringUtilTest { - - private String[] array; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - array = new String[] { - "foo", - "bar", - "baz" - }; - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - array = null; - } - - /** - * Test method for {@link JmStringUtil#containsIgnoreCase(String[], String)}. - */ - @Test - public void testContainsIgnoreCase() { - assertThat(JmStringUtil.containsIgnoreCase(array, "foo"), is(true)); - assertThat(JmStringUtil.containsIgnoreCase(array, "bar"), is(true)); - assertThat(JmStringUtil.containsIgnoreCase(array, "baz"), is(true)); - assertThat(JmStringUtil.containsIgnoreCase(array, "qux"), is(false)); - - assertThat(JmStringUtil.containsIgnoreCase(array, "FOO"), is(true)); - assertThat(JmStringUtil.containsIgnoreCase(array, "Bar"), is(true)); - assertThat(JmStringUtil.containsIgnoreCase(array, "bAz"), is(true)); - assertThat(JmStringUtil.containsIgnoreCase(array, "quX"), is(false)); - } - - /** - * Test method for {@link JmStringUtil#indexOfIgnoreCase(String[], String)}. - */ - @Test - public void testIndexOfIgnoreCaseStringArrayString() { - assertThat(JmStringUtil.indexOfIgnoreCase(array, "foo"), is(0)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "bar"), is(1)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "baz"), is(2)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "qux"), is(-1)); - - assertThat(JmStringUtil.indexOfIgnoreCase(array, "FOO"), is(0)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "Bar"), is(1)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "bAz"), is(2)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "quX"), is(-1)); - } - - /** - * Test method for {@link JmStringUtil#indexOfIgnoreCase(String[], String, int)}. - */ - @Test - public void testIndexOfIgnoreCaseStringArrayStringInt() { - assertThat(JmStringUtil.indexOfIgnoreCase(array, "foo", 1), is(-1)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "bar", 1), is(1)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "baz", 1), is(2)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "qux", 1), is(-1)); - - assertThat(JmStringUtil.indexOfIgnoreCase(array, "FOO", 1), is(-1)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "Bar", 1), is(1)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "bAz", 1), is(2)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "quX", 1), is(-1)); - } - - /** - * Test method for {@link JmStringUtil#toCapital(String)}. - */ - @Test - public void testToCapital() { - assertThat(JmStringUtil.toCapital("foo"), is("Foo")); - assertThat(JmStringUtil.toCapital("fooBar"), is("FooBar")); - assertThat(JmStringUtil.toCapital("qName"), is("QName")); - } - - /** - * Test method for {@link JmStringUtil#toJavaClassName(String)}. - */ - @Test - public void testToJavaClassNameString() { - assertThat(JmStringUtil.toJavaClassName("foo"), is("Foo")); -// assertThat(JmStringUtil.toJavaClassName("fooBar"), is("FooBar")); - assertThat(JmStringUtil.toJavaClassName("FOO_BAR"), is("FooBar")); - assertThat(JmStringUtil.toJavaClassName("Q_NAME"), is("QName")); - assertThat(JmStringUtil.toJavaClassName("SQL_STRING"), is("SqlString")); - } - - /** - * Test method for {@link JmStringUtil#toJavaClassName(String, String)}. - */ - @Test - public void testToJavaClassNameStringString() { - assertThat(JmStringUtil.toJavaClassName("HOGE_foo", "HOGE"), is("Foo")); -// assertThat(JmStringUtil.toJavaClassName("HOGE_fooBar", "HOGE"), is("FooBar")); - assertThat(JmStringUtil.toJavaClassName("HOGE_FOO_BAR", "HOGE"), is("FooBar")); - assertThat(JmStringUtil.toJavaClassName("HOGE_Q_NAME", "HOGE"), is("QName")); - assertThat(JmStringUtil.toJavaClassName("HOGE_SQL_STRING", "HOGE"), is("SqlString")); - } - - /** - * Test method for {@link JmStringUtil#toJavaName(String)}. - */ - @Test - public void testToJavaNameString() { - assertThat(JmStringUtil.toJavaName("foo"), is("foo")); -// assertThat(JmStringUtil.toJavaName("fooBar"), is("fooBar")); - assertThat(JmStringUtil.toJavaName("FOO_BAR"), is("fooBar")); - assertThat(JmStringUtil.toJavaName("Q_NAME"), is("qName")); - assertThat(JmStringUtil.toJavaName("SQL_STRING"), is("sqlString")); - } - - /** - * Test method for {@link JmStringUtil#toJavaName(String, String)}. - */ - @Test - public void testToJavaNameStringString() { -// fail("Not yet implemented"); - } - - /** - * Test method for {@link JmStringUtil#toSQLName(String, String)}. - */ - @Test - public void testToSQLName() { - assertThat(JmStringUtil.toSQLName("foo"), is("FOO")); -// assertThat(JmStringUtil.toSQLName("Foo"), is("FOO")); -// assertThat(JmStringUtil.toSQLName("FOO"), is("FOO")); - assertThat(JmStringUtil.toSQLName("fooBar"), is("FOO_BAR")); -// assertThat(JmStringUtil.toSQLName("FooBar"), is("FOO_BAR")); -// assertThat(JmStringUtil.toSQLName("FOO_BAR"), is("FOO_BAR")); - assertThat(JmStringUtil.toSQLName("qName"), is("Q_NAME")); -// assertThat(JmStringUtil.toSQLName("QName"), is("Q_NAME")); -// assertThat(JmStringUtil.toSQLName("Q_NAME"), is("Q_NAME")); - assertThat(JmStringUtil.toSQLName("sqlString"), is("SQL_STRING")); -// assertThat(JmStringUtil.toSQLName("SqlString"), is("SQL_STRING")); -// assertThat(JmStringUtil.toSQLName("SQL_STRING"), is("SQL_STRING")); - } - - /** - * Test method for {@link JmStringUtil#toUnCapital(String)}. - */ - @Test - public void testToUnCapital() { - assertThat(JmStringUtil.toUnCapital("Foo"), is("foo")); - assertThat(JmStringUtil.toUnCapital("FooBar"), is("fooBar")); - assertThat(JmStringUtil.toUnCapital("QName"), is("qName")); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/29 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * {@link JmStringUtil}のテストクラス。 + * + * @author daisuke + */ +public class JmStringUtilTest { + + private String[] array; + + + /** + * テストを初期化する。 + * + * @throws Exception 例外が発生した場合 + */ + @Before + public void setUp() throws Exception { + array = new String[] { + "foo", + "bar", + "baz" + }; + } + + /** + * テストの情報を破棄する。 + * + * @throws Exception 例外が発生した場合 + */ + @After + public void tearDown() throws Exception { + array = null; + } + + /** + * Test method for {@link JmStringUtil#containsIgnoreCase(String[], String)}. + */ + @Test + public void testContainsIgnoreCase() { + assertThat(JmStringUtil.containsIgnoreCase(array, "foo"), is(true)); + assertThat(JmStringUtil.containsIgnoreCase(array, "bar"), is(true)); + assertThat(JmStringUtil.containsIgnoreCase(array, "baz"), is(true)); + assertThat(JmStringUtil.containsIgnoreCase(array, "qux"), is(false)); + + assertThat(JmStringUtil.containsIgnoreCase(array, "FOO"), is(true)); + assertThat(JmStringUtil.containsIgnoreCase(array, "Bar"), is(true)); + assertThat(JmStringUtil.containsIgnoreCase(array, "bAz"), is(true)); + assertThat(JmStringUtil.containsIgnoreCase(array, "quX"), is(false)); + } + + /** + * Test method for {@link JmStringUtil#indexOfIgnoreCase(String[], String)}. + */ + @Test + public void testIndexOfIgnoreCaseStringArrayString() { + assertThat(JmStringUtil.indexOfIgnoreCase(array, "foo"), is(0)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "bar"), is(1)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "baz"), is(2)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "qux"), is(-1)); + + assertThat(JmStringUtil.indexOfIgnoreCase(array, "FOO"), is(0)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "Bar"), is(1)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "bAz"), is(2)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "quX"), is(-1)); + } + + /** + * Test method for {@link JmStringUtil#indexOfIgnoreCase(String[], String, int)}. + */ + @Test + public void testIndexOfIgnoreCaseStringArrayStringInt() { + assertThat(JmStringUtil.indexOfIgnoreCase(array, "foo", 1), is(-1)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "bar", 1), is(1)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "baz", 1), is(2)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "qux", 1), is(-1)); + + assertThat(JmStringUtil.indexOfIgnoreCase(array, "FOO", 1), is(-1)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "Bar", 1), is(1)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "bAz", 1), is(2)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "quX", 1), is(-1)); + } + + /** + * Test method for {@link JmStringUtil#toCapital(String)}. + */ + @Test + public void testToCapital() { + assertThat(JmStringUtil.toCapital("foo"), is("Foo")); + assertThat(JmStringUtil.toCapital("fooBar"), is("FooBar")); + assertThat(JmStringUtil.toCapital("qName"), is("QName")); + } + + /** + * Test method for {@link JmStringUtil#toJavaClassName(String)}. + */ + @Test + public void testToJavaClassNameString() { + assertThat(JmStringUtil.toJavaClassName("foo"), is("Foo")); +// assertThat(JmStringUtil.toJavaClassName("fooBar"), is("FooBar")); + assertThat(JmStringUtil.toJavaClassName("FOO_BAR"), is("FooBar")); + assertThat(JmStringUtil.toJavaClassName("Q_NAME"), is("QName")); + assertThat(JmStringUtil.toJavaClassName("SQL_STRING"), is("SqlString")); + } + + /** + * Test method for {@link JmStringUtil#toJavaClassName(String, String)}. + */ + @Test + public void testToJavaClassNameStringString() { + assertThat(JmStringUtil.toJavaClassName("HOGE_foo", "HOGE"), is("Foo")); +// assertThat(JmStringUtil.toJavaClassName("HOGE_fooBar", "HOGE"), is("FooBar")); + assertThat(JmStringUtil.toJavaClassName("HOGE_FOO_BAR", "HOGE"), is("FooBar")); + assertThat(JmStringUtil.toJavaClassName("HOGE_Q_NAME", "HOGE"), is("QName")); + assertThat(JmStringUtil.toJavaClassName("HOGE_SQL_STRING", "HOGE"), is("SqlString")); + } + + /** + * Test method for {@link JmStringUtil#toJavaName(String)}. + */ + @Test + public void testToJavaNameString() { + assertThat(JmStringUtil.toJavaName("foo"), is("foo")); +// assertThat(JmStringUtil.toJavaName("fooBar"), is("fooBar")); + assertThat(JmStringUtil.toJavaName("FOO_BAR"), is("fooBar")); + assertThat(JmStringUtil.toJavaName("Q_NAME"), is("qName")); + assertThat(JmStringUtil.toJavaName("SQL_STRING"), is("sqlString")); + } + + /** + * Test method for {@link JmStringUtil#toJavaName(String, String)}. + */ + @Test + public void testToJavaNameStringString() { +// fail("Not yet implemented"); + } + + /** + * Test method for {@link JmStringUtil#toSQLName(String, String)}. + */ + @Test + public void testToSQLName() { + assertThat(JmStringUtil.toSQLName("foo"), is("FOO")); +// assertThat(JmStringUtil.toSQLName("Foo"), is("FOO")); +// assertThat(JmStringUtil.toSQLName("FOO"), is("FOO")); + assertThat(JmStringUtil.toSQLName("fooBar"), is("FOO_BAR")); +// assertThat(JmStringUtil.toSQLName("FooBar"), is("FOO_BAR")); +// assertThat(JmStringUtil.toSQLName("FOO_BAR"), is("FOO_BAR")); + assertThat(JmStringUtil.toSQLName("qName"), is("Q_NAME")); +// assertThat(JmStringUtil.toSQLName("QName"), is("Q_NAME")); +// assertThat(JmStringUtil.toSQLName("Q_NAME"), is("Q_NAME")); + assertThat(JmStringUtil.toSQLName("sqlString"), is("SQL_STRING")); +// assertThat(JmStringUtil.toSQLName("SqlString"), is("SQL_STRING")); +// assertThat(JmStringUtil.toSQLName("SQL_STRING"), is("SQL_STRING")); + } + + /** + * Test method for {@link JmStringUtil#toUnCapital(String)}. + */ + @Test + public void testToUnCapital() { + assertThat(JmStringUtil.toUnCapital("Foo"), is("foo")); + assertThat(JmStringUtil.toUnCapital("FooBar"), is("fooBar")); + assertThat(JmStringUtil.toUnCapital("QName"), is("qName")); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/JmStringUtilTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ListUtilTest.java =================================================================== --- leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ListUtilTest.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ListUtilTest.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,134 +1,134 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/02/23 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * {@link ListUtil}のテストクラス。 - * - * @author daisuke - */ -public class ListUtilTest { - - private List<String> list; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - list = new ArrayList<String>(); - list.add("foo"); - list.add("bar"); - list.add("baz"); - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - list = null; - } - -// /** -// * {@link ListUtil#moveDown(List, int)}のテスト。 -// * -// * @throws Exception 例外が発生した場合 -// */ -// @Test -// public void test01_moveDown() throws Exception { -// try { -// ListUtil.moveDown(null, 0); -// fail(); -// } catch (IllegalArgumentException e) { -// // success -// } -// -// ListUtil.moveDown(list, 0); -// assertThat(list.get(0), is("bar")); -// assertThat(list.get(1), is("foo")); -// assertThat(list.get(2), is("baz")); -// -// ListUtil.moveDown(list, 1); -// assertThat(list.get(0), is("bar")); -// assertThat(list.get(1), is("baz")); -// assertThat(list.get(2), is("foo")); -// } -// -// /** -// * {@link ListUtil#moveUp(List, int)}のテスト。 -// * -// * @throws Exception 例外が発生した場合 -// */ -// @Test -// public void test02_moveUp() throws Exception { -// try { -// ListUtil.moveUp(list, -1); -// fail(); -// } catch (IllegalArgumentException e) { -// // success -// } -// -// ListUtil.moveUp(list, 1); -// assertThat(list.get(0), is("bar")); -// assertThat(list.get(1), is("foo")); -// assertThat(list.get(2), is("baz")); -// -// ListUtil.moveUp(list, 2); -// assertThat(list.get(0), is("bar")); -// assertThat(list.get(1), is("baz")); -// assertThat(list.get(2), is("foo")); -// } - - /** - * {@link ListUtil#reverse(List)}のテスト。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test03_reverse() throws Exception { - try { - ListUtil.reverse(null); - fail(); - } catch (IllegalArgumentException e) { - // success - } - - ListUtil.reverse(list); - assertThat(list.get(0), is("baz")); - assertThat(list.get(1), is("bar")); - assertThat(list.get(2), is("foo")); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/23 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * {@link ListUtil}のテストクラス。 + * + * @author daisuke + */ +public class ListUtilTest { + + private List<String> list; + + + /** + * テストを初期化する。 + * + * @throws Exception 例外が発生した場合 + */ + @Before + public void setUp() throws Exception { + list = new ArrayList<String>(); + list.add("foo"); + list.add("bar"); + list.add("baz"); + } + + /** + * テストの情報を破棄する。 + * + * @throws Exception 例外が発生した場合 + */ + @After + public void tearDown() throws Exception { + list = null; + } + +// /** +// * {@link ListUtil#moveDown(List, int)}のテスト。 +// * +// * @throws Exception 例外が発生した場合 +// */ +// @Test +// public void test01_moveDown() throws Exception { +// try { +// ListUtil.moveDown(null, 0); +// fail(); +// } catch (IllegalArgumentException e) { +// // success +// } +// +// ListUtil.moveDown(list, 0); +// assertThat(list.get(0), is("bar")); +// assertThat(list.get(1), is("foo")); +// assertThat(list.get(2), is("baz")); +// +// ListUtil.moveDown(list, 1); +// assertThat(list.get(0), is("bar")); +// assertThat(list.get(1), is("baz")); +// assertThat(list.get(2), is("foo")); +// } +// +// /** +// * {@link ListUtil#moveUp(List, int)}のテスト。 +// * +// * @throws Exception 例外が発生した場合 +// */ +// @Test +// public void test02_moveUp() throws Exception { +// try { +// ListUtil.moveUp(list, -1); +// fail(); +// } catch (IllegalArgumentException e) { +// // success +// } +// +// ListUtil.moveUp(list, 1); +// assertThat(list.get(0), is("bar")); +// assertThat(list.get(1), is("foo")); +// assertThat(list.get(2), is("baz")); +// +// ListUtil.moveUp(list, 2); +// assertThat(list.get(0), is("bar")); +// assertThat(list.get(1), is("baz")); +// assertThat(list.get(2), is("foo")); +// } + + /** + * {@link ListUtil#reverse(List)}のテスト。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test03_reverse() throws Exception { + try { + ListUtil.reverse(null); + fail(); + } catch (IllegalArgumentException e) { + // success + } + + ListUtil.reverse(list); + assertThat(list.get(0), is("baz")); + assertThat(list.get(1), is("bar")); + assertThat(list.get(2), is("foo")); + } +} Property changes on: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ListUtilTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java =================================================================== --- leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,291 +1,291 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/29 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * {@link ReflectionUtil}のテストクラス。 - * - * @author daisuke - */ -public class ReflectionUtilTest { - - private Method getFoo; - - private Method getBar; - - private Method isBaz; - - private Method getQux; - - private Method getQux2; - - private Method setFoo; - - private Method setBar; - - private Method setBaz; - - private Method setQux; - - private Method setQux2; - - private Field foo; - - private Field bar; - - private Field baz; - - private Field qux; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - foo = TestBean.class.getDeclaredField("foo"); - bar = TestBean.class.getDeclaredField("bar"); - baz = TestBean.class.getDeclaredField("baz"); - qux = TestBean.class.getDeclaredField("qux"); - - getFoo = TestBean.class.getDeclaredMethod("getFoo"); - getBar = TestBean.class.getDeclaredMethod("getBar"); - isBaz = TestBean.class.getDeclaredMethod("isBaz"); - getQux = TestBean.class.getDeclaredMethod("getQux"); - getQux2 = TestBean.class.getDeclaredMethod("getQux2"); - - setFoo = TestBean.class.getDeclaredMethod("setFoo", int.class); - setBar = TestBean.class.getDeclaredMethod("setBar", String.class); - setBaz = TestBean.class.getDeclaredMethod("setBaz", boolean.class); - setQux = TestBean.class.getDeclaredMethod("setQux", Boolean.class); - setQux2 = TestBean.class.getDeclaredMethod("setQux2"); - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - getFoo = null; - getBar = null; - isBaz = null; - getQux = null; - getQux2 = null; - - setFoo = null; - setBar = null; - setBaz = null; - setQux = null; - setQux2 = null; - } - - /** - * Test method for {@link ReflectionUtil#convertFieldToAccessorName(java.lang.reflect.Field, String)}. - */ - @Test - public void testConvertFieldToAccessorName() { - assertThat(ReflectionUtil.convertFieldToAccessorName(foo, "get"), is("getFoo")); - assertThat(ReflectionUtil.convertFieldToAccessorName(bar, "get"), is("getBar")); - assertThat(ReflectionUtil.convertFieldToAccessorName(baz, "is"), is("isBaz")); - assertThat(ReflectionUtil.convertFieldToAccessorName(qux, "get"), is("getQux")); - - assertThat(ReflectionUtil.convertFieldToAccessorName(foo, "set"), is("setFoo")); - assertThat(ReflectionUtil.convertFieldToAccessorName(bar, "set"), is("setBar")); - assertThat(ReflectionUtil.convertFieldToAccessorName(baz, "set"), is("setBaz")); - assertThat(ReflectionUtil.convertFieldToAccessorName(qux, "set"), is("setQux")); - } - - /** - * Test method for {@link ReflectionUtil#convertFieldToGetterName(java.lang.reflect.Field)}. - */ - @Test - public void testConvertFieldToGetterName() { - assertThat(ReflectionUtil.convertFieldToGetterName(foo), is("getFoo")); - assertThat(ReflectionUtil.convertFieldToGetterName(bar), is("getBar")); - assertThat(ReflectionUtil.convertFieldToGetterName(baz), is("isBaz")); - assertThat(ReflectionUtil.convertFieldToGetterName(qux), is("isQux")); - } - - /** - * Test method for {@link ReflectionUtil#convertFieldToSetterName(java.lang.reflect.Field)}. - */ - @Test - public void testConvertFieldToSetterName() { - assertThat(ReflectionUtil.convertFieldToSetterName(foo), is("setFoo")); - assertThat(ReflectionUtil.convertFieldToSetterName(bar), is("setBar")); - assertThat(ReflectionUtil.convertFieldToSetterName(baz), is("setBaz")); - assertThat(ReflectionUtil.convertFieldToSetterName(qux), is("setQux")); - } - - /** - * Test method for {@link ReflectionUtil#convertAccessorToFieldName(java.lang.reflect.Method)}. - */ - @Test - public void testConvertGetterToFieldName() { - assertThat(ReflectionUtil.convertAccessorToFieldName(getFoo), is("foo")); - assertThat(ReflectionUtil.convertAccessorToFieldName(getBar), is("bar")); - assertThat(ReflectionUtil.convertAccessorToFieldName(isBaz), is("baz")); - assertThat(ReflectionUtil.convertAccessorToFieldName(getQux), is("qux")); - try { - ReflectionUtil.convertAccessorToFieldName(getQux2); - fail(); - } catch (IllegalArgumentException e) { - // success - } - - assertThat(ReflectionUtil.convertAccessorToFieldName(setFoo), is("foo")); - assertThat(ReflectionUtil.convertAccessorToFieldName(setBar), is("bar")); - assertThat(ReflectionUtil.convertAccessorToFieldName(setBaz), is("baz")); - assertThat(ReflectionUtil.convertAccessorToFieldName(setQux), is("qux")); - try { - ReflectionUtil.convertAccessorToFieldName(setQux2); - fail(); - } catch (IllegalArgumentException e) { - // success - } - - } - - /** - * Test method for {@link ReflectionUtil#isAccessor(java.lang.reflect.Method)}. - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void testIsAccessor() throws Exception { - assertThat(ReflectionUtil.isAccessor(getFoo), is(true)); - assertThat(ReflectionUtil.isAccessor(getBar), is(true)); - assertThat(ReflectionUtil.isAccessor(isBaz), is(true)); - assertThat(ReflectionUtil.isAccessor(getQux), is(true)); - assertThat(ReflectionUtil.isAccessor(getQux2), is(false)); - - assertThat(ReflectionUtil.isAccessor(setFoo), is(true)); - assertThat(ReflectionUtil.isAccessor(setBar), is(true)); - assertThat(ReflectionUtil.isAccessor(setBaz), is(true)); - assertThat(ReflectionUtil.isAccessor(setQux), is(true)); - assertThat(ReflectionUtil.isAccessor(setQux2), is(false)); - } - - /** - * Test method for {@link ReflectionUtil#isGetter(java.lang.reflect.Method)}. - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void testIsGetter() throws Exception { - assertThat(ReflectionUtil.isGetter(getFoo), is(true)); - assertThat(ReflectionUtil.isGetter(getBar), is(true)); - assertThat(ReflectionUtil.isGetter(isBaz), is(true)); - assertThat(ReflectionUtil.isGetter(getQux), is(true)); - assertThat(ReflectionUtil.isGetter(getQux2), is(false)); - - assertThat(ReflectionUtil.isGetter(setFoo), is(false)); - assertThat(ReflectionUtil.isGetter(setBar), is(false)); - assertThat(ReflectionUtil.isGetter(setBaz), is(false)); - assertThat(ReflectionUtil.isGetter(setQux), is(false)); - assertThat(ReflectionUtil.isGetter(setQux2), is(false)); - } - - /** - * Test method for {@link ReflectionUtil#isSetter(java.lang.reflect.Method)}. - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void testIsSetter() throws Exception { - assertThat(ReflectionUtil.isSetter(getFoo), is(false)); - assertThat(ReflectionUtil.isSetter(getBar), is(false)); - assertThat(ReflectionUtil.isSetter(isBaz), is(false)); - assertThat(ReflectionUtil.isSetter(getQux), is(false)); - assertThat(ReflectionUtil.isSetter(getQux2), is(false)); - - assertThat(ReflectionUtil.isSetter(setFoo), is(true)); - assertThat(ReflectionUtil.isSetter(setBar), is(true)); - assertThat(ReflectionUtil.isSetter(setBaz), is(true)); - assertThat(ReflectionUtil.isSetter(setQux), is(true)); - assertThat(ReflectionUtil.isSetter(setQux2), is(false)); - } - - - class TestBean { - - private int foo; - - private String bar; - - private boolean baz; - - private Boolean qux; - - - String getBar() { - return bar; - } - - int getFoo() { - return foo; - } - - Boolean getQux() { - return qux; - } - - void getQux2() { - } - - boolean isBaz() { - return baz; - } - - void setBar(String bar) { - this.bar = bar; - } - - void setBaz(boolean baz) { - this.baz = baz; - } - - void setFoo(int foo) { - this.foo = foo; - } - - void setQux(Boolean qux) { - this.qux = qux; - } - - void setQux2() { - } - - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/29 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * {@link ReflectionUtil}のテストクラス。 + * + * @author daisuke + */ +public class ReflectionUtilTest { + + private Method getFoo; + + private Method getBar; + + private Method isBaz; + + private Method getQux; + + private Method getQux2; + + private Method setFoo; + + private Method setBar; + + private Method setBaz; + + private Method setQux; + + private Method setQux2; + + private Field foo; + + private Field bar; + + private Field baz; + + private Field qux; + + + /** + * テストを初期化する。 + * + * @throws Exception 例外が発生した場合 + */ + @Before + public void setUp() throws Exception { + foo = TestBean.class.getDeclaredField("foo"); + bar = TestBean.class.getDeclaredField("bar"); + baz = TestBean.class.getDeclaredField("baz"); + qux = TestBean.class.getDeclaredField("qux"); + + getFoo = TestBean.class.getDeclaredMethod("getFoo"); + getBar = TestBean.class.getDeclaredMethod("getBar"); + isBaz = TestBean.class.getDeclaredMethod("isBaz"); + getQux = TestBean.class.getDeclaredMethod("getQux"); + getQux2 = TestBean.class.getDeclaredMethod("getQux2"); + + setFoo = TestBean.class.getDeclaredMethod("setFoo", int.class); + setBar = TestBean.class.getDeclaredMethod("setBar", String.class); + setBaz = TestBean.class.getDeclaredMethod("setBaz", boolean.class); + setQux = TestBean.class.getDeclaredMethod("setQux", Boolean.class); + setQux2 = TestBean.class.getDeclaredMethod("setQux2"); + } + + /** + * テストの情報を破棄する。 + * + * @throws Exception 例外が発生した場合 + */ + @After + public void tearDown() throws Exception { + getFoo = null; + getBar = null; + isBaz = null; + getQux = null; + getQux2 = null; + + setFoo = null; + setBar = null; + setBaz = null; + setQux = null; + setQux2 = null; + } + + /** + * Test method for {@link ReflectionUtil#convertFieldToAccessorName(java.lang.reflect.Field, String)}. + */ + @Test + public void testConvertFieldToAccessorName() { + assertThat(ReflectionUtil.convertFieldToAccessorName(foo, "get"), is("getFoo")); + assertThat(ReflectionUtil.convertFieldToAccessorName(bar, "get"), is("getBar")); + assertThat(ReflectionUtil.convertFieldToAccessorName(baz, "is"), is("isBaz")); + assertThat(ReflectionUtil.convertFieldToAccessorName(qux, "get"), is("getQux")); + + assertThat(ReflectionUtil.convertFieldToAccessorName(foo, "set"), is("setFoo")); + assertThat(ReflectionUtil.convertFieldToAccessorName(bar, "set"), is("setBar")); + assertThat(ReflectionUtil.convertFieldToAccessorName(baz, "set"), is("setBaz")); + assertThat(ReflectionUtil.convertFieldToAccessorName(qux, "set"), is("setQux")); + } + + /** + * Test method for {@link ReflectionUtil#convertFieldToGetterName(java.lang.reflect.Field)}. + */ + @Test + public void testConvertFieldToGetterName() { + assertThat(ReflectionUtil.convertFieldToGetterName(foo), is("getFoo")); + assertThat(ReflectionUtil.convertFieldToGetterName(bar), is("getBar")); + assertThat(ReflectionUtil.convertFieldToGetterName(baz), is("isBaz")); + assertThat(ReflectionUtil.convertFieldToGetterName(qux), is("isQux")); + } + + /** + * Test method for {@link ReflectionUtil#convertFieldToSetterName(java.lang.reflect.Field)}. + */ + @Test + public void testConvertFieldToSetterName() { + assertThat(ReflectionUtil.convertFieldToSetterName(foo), is("setFoo")); + assertThat(ReflectionUtil.convertFieldToSetterName(bar), is("setBar")); + assertThat(ReflectionUtil.convertFieldToSetterName(baz), is("setBaz")); + assertThat(ReflectionUtil.convertFieldToSetterName(qux), is("setQux")); + } + + /** + * Test method for {@link ReflectionUtil#convertAccessorToFieldName(java.lang.reflect.Method)}. + */ + @Test + public void testConvertGetterToFieldName() { + assertThat(ReflectionUtil.convertAccessorToFieldName(getFoo), is("foo")); + assertThat(ReflectionUtil.convertAccessorToFieldName(getBar), is("bar")); + assertThat(ReflectionUtil.convertAccessorToFieldName(isBaz), is("baz")); + assertThat(ReflectionUtil.convertAccessorToFieldName(getQux), is("qux")); + try { + ReflectionUtil.convertAccessorToFieldName(getQux2); + fail(); + } catch (IllegalArgumentException e) { + // success + } + + assertThat(ReflectionUtil.convertAccessorToFieldName(setFoo), is("foo")); + assertThat(ReflectionUtil.convertAccessorToFieldName(setBar), is("bar")); + assertThat(ReflectionUtil.convertAccessorToFieldName(setBaz), is("baz")); + assertThat(ReflectionUtil.convertAccessorToFieldName(setQux), is("qux")); + try { + ReflectionUtil.convertAccessorToFieldName(setQux2); + fail(); + } catch (IllegalArgumentException e) { + // success + } + + } + + /** + * Test method for {@link ReflectionUtil#isAccessor(java.lang.reflect.Method)}. + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void testIsAccessor() throws Exception { + assertThat(ReflectionUtil.isAccessor(getFoo), is(true)); + assertThat(ReflectionUtil.isAccessor(getBar), is(true)); + assertThat(ReflectionUtil.isAccessor(isBaz), is(true)); + assertThat(ReflectionUtil.isAccessor(getQux), is(true)); + assertThat(ReflectionUtil.isAccessor(getQux2), is(false)); + + assertThat(ReflectionUtil.isAccessor(setFoo), is(true)); + assertThat(ReflectionUtil.isAccessor(setBar), is(true)); + assertThat(ReflectionUtil.isAccessor(setBaz), is(true)); + assertThat(ReflectionUtil.isAccessor(setQux), is(true)); + assertThat(ReflectionUtil.isAccessor(setQux2), is(false)); + } + + /** + * Test method for {@link ReflectionUtil#isGetter(java.lang.reflect.Method)}. + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void testIsGetter() throws Exception { + assertThat(ReflectionUtil.isGetter(getFoo), is(true)); + assertThat(ReflectionUtil.isGetter(getBar), is(true)); + assertThat(ReflectionUtil.isGetter(isBaz), is(true)); + assertThat(ReflectionUtil.isGetter(getQux), is(true)); + assertThat(ReflectionUtil.isGetter(getQux2), is(false)); + + assertThat(ReflectionUtil.isGetter(setFoo), is(false)); + assertThat(ReflectionUtil.isGetter(setBar), is(false)); + assertThat(ReflectionUtil.isGetter(setBaz), is(false)); + assertThat(ReflectionUtil.isGetter(setQux), is(false)); + assertThat(ReflectionUtil.isGetter(setQux2), is(false)); + } + + /** + * Test method for {@link ReflectionUtil#isSetter(java.lang.reflect.Method)}. + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void testIsSetter() throws Exception { + assertThat(ReflectionUtil.isSetter(getFoo), is(false)); + assertThat(ReflectionUtil.isSetter(getBar), is(false)); + assertThat(ReflectionUtil.isSetter(isBaz), is(false)); + assertThat(ReflectionUtil.isSetter(getQux), is(false)); + assertThat(ReflectionUtil.isSetter(getQux2), is(false)); + + assertThat(ReflectionUtil.isSetter(setFoo), is(true)); + assertThat(ReflectionUtil.isSetter(setBar), is(true)); + assertThat(ReflectionUtil.isSetter(setBaz), is(true)); + assertThat(ReflectionUtil.isSetter(setQux), is(true)); + assertThat(ReflectionUtil.isSetter(setQux2), is(false)); + } + + + class TestBean { + + private int foo; + + private String bar; + + private boolean baz; + + private Boolean qux; + + + String getBar() { + return bar; + } + + int getFoo() { + return foo; + } + + Boolean getQux() { + return qux; + } + + void getQux2() { + } + + boolean isBaz() { + return baz; + } + + void setBar(String bar) { + this.bar = bar; + } + + void setBaz(boolean baz) { + this.baz = baz; + } + + void setFoo(int foo) { + this.foo = foo; + } + + void setQux(Boolean qux) { + this.qux = qux; + } + + void setQux2() { + } + + } +} Property changes on: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/SqlExecutorTest.java =================================================================== --- leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/SqlExecutorTest.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/SqlExecutorTest.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,110 +1,110 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/05/22 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.junit.Assert.assertThat; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; - -import org.h2.Driver; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.jiemamy.utils.SqlExecutor.SqlExecutorHandler; - -/** - * {@link SqlExecutor} のテストクラス。 - * - * @author Keisuke.K - */ -public class SqlExecutorTest { - - /** - * テストクラスの初期化。 - * - * <p> - * H2ドライバを登録する。 - * </p> - * - * @throws java.lang.Exception 例外が発生した場合 - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - DriverManager.registerDriver(new Driver()); - } - - - private Connection conn; - - - /** - * テストの初期化。 - * - * <p> - * H2コネクションを取得する。 - * </p> - * - * @throws java.lang.Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - conn = DriverManager.getConnection("jdbc:h2:test", "sa", ""); - } - - /** - * テストの終了処理。 - * - * <p> - * H2コネクションをクローズする。 - * </p> - * - * @throws java.lang.Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - JmIOUtil.closeQuietly(conn); - } - - /** - * 単純なSQLを実行し、正しくResultSetが取得できるかを確認する。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test01_単純なSQLの実行() throws Exception { - SqlExecutor executor = new SqlExecutor(conn); - SqlExecutorHandler handler = new SqlExecutorHandler() { - - public void sqlExecuted(String sql, ResultSet rs) { - assertThat(sql, is("SELECT * FROM DUAL")); - assertThat(rs, is(notNullValue())); - } - - }; - - executor.setHandler(handler); - executor.execute("SELECT * FROM DUAL"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/05/22 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.Assert.assertThat; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; + +import org.h2.Driver; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.jiemamy.utils.SqlExecutor.SqlExecutorHandler; + +/** + * {@link SqlExecutor} のテストクラス。 + * + * @author Keisuke.K + */ +public class SqlExecutorTest { + + /** + * テストクラスの初期化。 + * + * <p> + * H2ドライバを登録する。 + * </p> + * + * @throws java.lang.Exception 例外が発生した場合 + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + DriverManager.registerDriver(new Driver()); + } + + + private Connection conn; + + + /** + * テストの初期化。 + * + * <p> + * H2コネクションを取得する。 + * </p> + * + * @throws java.lang.Exception 例外が発生した場合 + */ + @Before + public void setUp() throws Exception { + conn = DriverManager.getConnection("jdbc:h2:test", "sa", ""); + } + + /** + * テストの終了処理。 + * + * <p> + * H2コネクションをクローズする。 + * </p> + * + * @throws java.lang.Exception 例外が発生した場合 + */ + @After + public void tearDown() throws Exception { + JmIOUtil.closeQuietly(conn); + } + + /** + * 単純なSQLを実行し、正しくResultSetが取得できるかを確認する。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test01_単純なSQLの実行() throws Exception { + SqlExecutor executor = new SqlExecutor(conn); + SqlExecutorHandler handler = new SqlExecutorHandler() { + + public void sqlExecuted(String sql, ResultSet rs) { + assertThat(sql, is("SELECT * FROM DUAL")); + assertThat(rs, is(notNullValue())); + } + + }; + + executor.setHandler(handler); + executor.execute("SELECT * FROM DUAL"); + } +} Property changes on: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/SqlExecutorTest.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/UUIDUtilTest.java =================================================================== --- leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/UUIDUtilTest.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/UUIDUtilTest.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,50 +1,50 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/17 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.utils; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; - -import java.util.UUID; - -import org.junit.Test; - -/** - * {@link UUIDUtil}のテストクラス。 - * - * @author daisuke - */ -public class UUIDUtilTest { - - /** - * Test method for {@link org.jiemamy.utils.UUIDUtil#valueOfOrRandom(java.lang.String)}. - */ - @Test - public void testValueOfOrRandom() { - // UUID化できるStringを与えた場合 → fromString生成 - UUID uuid1 = UUIDUtil.valueOfOrRandom("ffffffff-ffff-ffff-ffff-ffffffffffff"); - assertThat(uuid1.toString(), is("ffffffff-ffff-ffff-ffff-ffffffffffff")); - - // UUID化できないStringを与えた場合 → randomUUID生成 - UUID uuid2 = UUIDUtil.valueOfOrRandom("hoge"); - assertThat(uuid2.toString(), not("hoge")); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/17 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.utils; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertThat; + +import java.util.UUID; + +import org.junit.Test; + +/** + * {@link UUIDUtil}のテストクラス。 + * + * @author daisuke + */ +public class UUIDUtilTest { + + /** + * Test method for {@link org.jiemamy.utils.UUIDUtil#valueOfOrRandom(java.lang.String)}. + */ + @Test + public void testValueOfOrRandom() { + // UUID化できるStringを与えた場合 → fromString生成 + UUID uuid1 = UUIDUtil.valueOfOrRandom("ffffffff-ffff-ffff-ffff-ffffffffffff"); + assertThat(uuid1.toString(), is("ffffffff-ffff-ffff-ffff-ffffffffffff")); + + // UUID化できないStringを与えた場合 → randomUUID生成 + UUID uuid2 = UUIDUtil.valueOfOrRandom("hoge"); + assertThat(uuid2.toString(), not("hoge")); + } + +} Property changes on: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/UUIDUtilTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-commons/trunk/src/test/resources/logback.xml =================================================================== --- leto/jiemamy-commons/trunk/src/test/resources/logback.xml 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-commons/trunk/src/test/resources/logback.xml 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,18 +1,18 @@ -<?xml version="1.0" encoding="UTF-8"?> -<configuration> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <Target>System.out</Target> - <layout class="ch.qos.logback.classic.PatternLayout"> - <Pattern>%d{HH:mm:ss.SSS z,JST} [%thread] %-5level %logger{36} - %msg%n</Pattern> - </layout> - </appender> - - <root> - <level value="WARN" /> - <appender-ref ref="STDOUT" /> - </root> - - <logger name="org.jiemamy.utils.enhancer"> - <level value="TRACE" /> - </logger> -</configuration> +<?xml version="1.0" encoding="UTF-8"?> +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <Target>System.out</Target> + <layout class="ch.qos.logback.classic.PatternLayout"> + <Pattern>%d{HH:mm:ss.SSS z,JST} [%thread] %-5level %logger{36} - %msg%n</Pattern> + </layout> + </appender> + + <root> + <level value="WARN" /> + <appender-ref ref="STDOUT" /> + </root> + + <logger name="org.jiemamy.utils.enhancer"> + <level value="TRACE" /> + </logger> +</configuration> Property changes on: leto/jiemamy-commons/trunk/src/test/resources/logback.xml ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/LICENSE.txt =================================================================== --- leto/jiemamy-entity-io/trunk/LICENSE.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/LICENSE.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. Property changes on: leto/jiemamy-entity-io/trunk/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/license/LICENSE.hamcrest.txt =================================================================== --- leto/jiemamy-entity-io/trunk/license/LICENSE.hamcrest.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/license/LICENSE.hamcrest.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,27 +1,27 @@ -BSD License - -Copyright (c) 2000-2006, www.hamcrest.org -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of -conditions and the following disclaimer. Redistributions in binary form must reproduce -the above copyright notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -Neither the name of Hamcrest nor the names of its contributors may be used to endorse -or promote products derived from this software without specific prior written -permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT -SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY -WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. +BSD License + +Copyright (c) 2000-2006, www.hamcrest.org +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. Redistributions in binary form must reproduce +the above copyright notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the distribution. + +Neither the name of Hamcrest nor the names of its contributors may be used to endorse +or promote products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. Property changes on: leto/jiemamy-entity-io/trunk/license/LICENSE.hamcrest.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/jiemamy-entity-io/trunk/license/LICENSE.junit.html ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/html Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/license/LICENSE.logback.txt =================================================================== --- leto/jiemamy-entity-io/trunk/license/LICENSE.logback.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/license/LICENSE.logback.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,22 +1,22 @@ -Logback LICENSE ---------------- - -Logback: the reliable, generic, fast and flexible logging library for -Java. - -Copyright (C) 2000-2008, QOS.ch - -Source code and binaries for logback, including logback-core, -logback-classic and logback-access modules, are distributed under the -GNU Lesser General Public License Version 2.1, as published by the -Free Software Foundation. - -This library 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 2.1 of the -License, or (at your option) any later version. - -This library 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. +Logback LICENSE +--------------- + +Logback: the reliable, generic, fast and flexible logging library for +Java. + +Copyright (C) 2000-2008, QOS.ch + +Source code and binaries for logback, including logback-core, +logback-classic and logback-access modules, are distributed under the +GNU Lesser General Public License Version 2.1, as published by the +Free Software Foundation. + +This library 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 2.1 of the +License, or (at your option) any later version. + +This library 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. Property changes on: leto/jiemamy-entity-io/trunk/license/LICENSE.logback.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/license/LICENSE.slf4j.txt =================================================================== --- leto/jiemamy-entity-io/trunk/license/LICENSE.slf4j.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/license/LICENSE.slf4j.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,24 +1,24 @@ -Copyright (c) 2004-2008 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - +Copyright (c) 2004-2008 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + Property changes on: leto/jiemamy-entity-io/trunk/license/LICENSE.slf4j.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/license/list.txt =================================================================== --- leto/jiemamy-entity-io/trunk/license/list.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/license/list.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,14 +1,14 @@ -MIT License: - SLF4J API Module, - JCL 1.1.1 implemented over SLF4J - -BSD style: - Hamcrest Core, - Hamcrest Library, - -Common Public License Version 1.0: - JUnit - -GNU Lesser General Public License: - Logback Classic Module, - Logback Core Module +MIT License: + SLF4J API Module, + JCL 1.1.1 implemented over SLF4J + +BSD style: + Hamcrest Core, + Hamcrest Library, + +Common Public License Version 1.0: + JUnit + +GNU Lesser General Public License: + Logback Classic Module, + Logback Core Module Property changes on: leto/jiemamy-entity-io/trunk/license/list.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/pom.xml =================================================================== --- leto/jiemamy-entity-io/trunk/pom.xml 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/pom.xml 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,140 +1,140 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.jiemamy</groupId> - <artifactId>master</artifactId> - <version>1.1</version> - </parent> - <groupId>org.jiemamy</groupId> - <artifactId>jiemamy-entity-io</artifactId> - <name>Jiemamy JPA Entity I/O</name> - <version>0.0.1-SNAPSHOT</version> - <url>http://report.jiemamy.org/jiemamy-entity-io</url> - <issueManagement> - <system>JIRA</system> - <url>http://jira.jiemamy.org/jira/browse/EIO</url> - </issueManagement> - <ciManagement> - <system>hudson</system> - <url>http://hudson.jiemamy.org/hudson/job/jiemamy-entity-io/</url> - <notifiers> - <notifier> - <sendOnSuccess>false</sendOnSuccess> - <configuration> - <recipients>jiema****@googl*****</recipients> - </configuration> - </notifier> - </notifiers> - </ciManagement> - <inceptionYear>2009</inceptionYear> - <developers> - <developer> - <id>j5ik2o</id> - <name>Junichi Kato</name> - <email>j5ik2****@users*****</email> - <url>http://d.hatena.ne.jp/j5ik2o/</url> - <timezone>+9</timezone> - </developer> - </developers> - <scm> - <connection>scm:svn:http://svn.sourceforge.jp/svnroot/jiemamy/leto/jiemamy-entity-io/trunk</connection> - <developerConnection>scm:svn:svn+ssh://svn.sourceforge.jp/svnroot/jiemamy/leto/jiemamy-entity-io/trunk</developerConnection> - <url>http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi/leto/jiemamy-entity-io/trunk/?root=jiemamy</url> - </scm> - <repositories> - <repository> - <id>jiemamy.org</id> - <name>Jiemamy Repository</name> - <url>http://maven.jiemamy.org/release</url> - </repository> - </repositories> - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.5</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <version>1.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>1.5.6</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> - <version>1.5.6</version> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-core</artifactId> - <version>0.9.15</version> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <version>0.9.15</version> - </dependency> - <dependency> - <groupId>commons-beanutils</groupId> - <artifactId>commons-beanutils</artifactId> - <version>1.8.0</version> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.4</version> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>1.3.2</version> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jpa_3.0_spec</artifactId> - <version>1.1.1</version> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jiemamy-commons</artifactId> - <version>0.0.3</version> - </dependency> - <dependency> - <groupId>org.freemarker</groupId> - <artifactId>freemarker</artifactId> - <version>2.3.13</version> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-annotation_1.0_spec</artifactId> - <version>1.0</version> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jiemamy-spec-core</artifactId> - <version>0.2</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.jiemamy</groupId> - <artifactId>jiemamy-test-helper</artifactId> - <version>0.0.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jiemamy-core</artifactId> - <version>0.2.0</version> - <scope>test</scope> - </dependency> - </dependencies> +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.jiemamy</groupId> + <artifactId>master</artifactId> + <version>1.1</version> + </parent> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-entity-io</artifactId> + <name>Jiemamy JPA Entity I/O</name> + <version>0.0.1-SNAPSHOT</version> + <url>http://report.jiemamy.org/jiemamy-entity-io</url> + <issueManagement> + <system>JIRA</system> + <url>http://jira.jiemamy.org/jira/browse/EIO</url> + </issueManagement> + <ciManagement> + <system>hudson</system> + <url>http://hudson.jiemamy.org/hudson/job/jiemamy-entity-io/</url> + <notifiers> + <notifier> + <sendOnSuccess>false</sendOnSuccess> + <configuration> + <recipients>jiema****@googl*****</recipients> + </configuration> + </notifier> + </notifiers> + </ciManagement> + <inceptionYear>2009</inceptionYear> + <developers> + <developer> + <id>j5ik2o</id> + <name>Junichi Kato</name> + <email>j5ik2****@users*****</email> + <url>http://d.hatena.ne.jp/j5ik2o/</url> + <timezone>+9</timezone> + </developer> + </developers> + <scm> + <connection>scm:svn:http://svn.sourceforge.jp/svnroot/jiemamy/leto/jiemamy-entity-io/trunk</connection> + <developerConnection>scm:svn:svn+ssh://svn.sourceforge.jp/svnroot/jiemamy/leto/jiemamy-entity-io/trunk</developerConnection> + <url>http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi/leto/jiemamy-entity-io/trunk/?root=jiemamy</url> + </scm> + <repositories> + <repository> + <id>jiemamy.org</id> + <name>Jiemamy Repository</name> + <url>http://maven.jiemamy.org/release</url> + </repository> + </repositories> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-library</artifactId> + <version>1.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.5.6</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>1.5.6</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>0.9.15</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>0.9.15</version> + </dependency> + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + <version>1.8.0</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.4</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>1.3.2</version> + </dependency> + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-jpa_3.0_spec</artifactId> + <version>1.1.1</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>jiemamy-commons</artifactId> + <version>0.0.3</version> + </dependency> + <dependency> + <groupId>org.freemarker</groupId> + <artifactId>freemarker</artifactId> + <version>2.3.13</version> + </dependency> + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-annotation_1.0_spec</artifactId> + <version>1.0</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>jiemamy-spec-core</artifactId> + <version>0.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-test-helper</artifactId> + <version>0.0.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>jiemamy-core</artifactId> + <version>0.2.0</version> + <scope>test</scope> + </dependency> + </dependencies> </project> \ No newline at end of file Property changes on: leto/jiemamy-entity-io/trunk/pom.xml ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/ProductInfo.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/ProductInfo.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/ProductInfo.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,182 +1,182 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import org.jiemamy.exception.JiemamyError; - -/** - * プロダクト情報。 - * - * @author j5ik2o - */ -public class ProductInfo { - - /** - * プロダクト情報のホルダ。 - * - * @author j5ik2o - */ - protected static class ProductInfoHolder { - - /** POMのプロパティファイルのパス */ - protected static final String POM_PROPERTIES_PATH = - "META-INF/maven/org.jiemamy/jiemamy-entity-io/pom.properties"; - - /** プロダクト情報 */ - protected static final ProductInfo PRODUCT_INFO = createProductInfo(); - - - /** - * プロダクト情報を取得する。 - * - * @return プロダクト情報 - */ - protected static ProductInfo createProductInfo() { - Properties props = loadProperties(); - return new ProductInfo(props.getProperty("version"), props.getProperty("groupId"), props - .getProperty("artifactId")); - } - - /** - * プロパティをロードし取得する。 - * - * @return プロパティ - */ - protected static Properties loadProperties() { - InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(POM_PROPERTIES_PATH); - Properties props = new Properties(); - if (is != null) { - try { - props.load(is); - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - is.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return props; - } - - /** - * インスタンスを生成する。 - * - */ - protected ProductInfoHolder() { - throw new JiemamyError("不到達ポイント"); - } - } - - - /** プロダクト名 */ - protected static final String PRODUCT_NAME = "Jiemamy EntityIO"; - - /** 不明な値 */ - protected static final String UNKNOWN = "unknown"; - - - /** - * シングルトンの{@link ProductInfo}を取得する。 - * - * @return シングルトンの{@link ProductInfo} - */ - public static ProductInfo getInstance() { - return ProductInfoHolder.PRODUCT_INFO; - } - - /** - * プロダクト情報を標準出力へ出力する。 - * - * @param args プログラム引数 - */ - public static void main(String[] args) { - ProductInfo info = ProductInfoHolder.PRODUCT_INFO; - System.out.printf("jiemamy entity io name : %s\n", info.getName()); - System.out.printf("jiemamy entity io version : %s\n", info.getVersion()); - System.out.printf("jiemamy entity io groupId : %s\n", info.getGroupId()); - System.out.printf("jiemamy entity io artifactId : %s\n", info.getArtifactId()); - } - - - /** groupId */ - protected final String groupId; - - /** artifactId */ - protected final String artifactId; - - /** バージョン */ - protected final String version; - - - /** - * インスタンスを生成する。 - * - * @param version バージョン - * @param groupId グループID - * @param artifactId アーティファクトID - */ - protected ProductInfo(String version, String groupId, String artifactId) { - this.version = version != null ? version : UNKNOWN; - this.groupId = groupId != null ? groupId : UNKNOWN; - this.artifactId = artifactId != null ? artifactId : UNKNOWN; - } - - /** - * artifactIdを取得する。 - * - * @return artifactId - */ - public String getArtifactId() { - return artifactId; - } - - /** - * groupIdを取得する。 - * - * @return groupId - */ - public String getGroupId() { - return groupId; - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return PRODUCT_NAME; - } - - /** - * バージョンを取得する。 - * - * @return バージョン - */ - public String getVersion() { - return version; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.jiemamy.exception.JiemamyError; + +/** + * プロダクト情報。 + * + * @author j5ik2o + */ +public class ProductInfo { + + /** + * プロダクト情報のホルダ。 + * + * @author j5ik2o + */ + protected static class ProductInfoHolder { + + /** POMのプロパティファイルのパス */ + protected static final String POM_PROPERTIES_PATH = + "META-INF/maven/org.jiemamy/jiemamy-entity-io/pom.properties"; + + /** プロダクト情報 */ + protected static final ProductInfo PRODUCT_INFO = createProductInfo(); + + + /** + * プロダクト情報を取得する。 + * + * @return プロダクト情報 + */ + protected static ProductInfo createProductInfo() { + Properties props = loadProperties(); + return new ProductInfo(props.getProperty("version"), props.getProperty("groupId"), props + .getProperty("artifactId")); + } + + /** + * プロパティをロードし取得する。 + * + * @return プロパティ + */ + protected static Properties loadProperties() { + InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(POM_PROPERTIES_PATH); + Properties props = new Properties(); + if (is != null) { + try { + props.load(is); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return props; + } + + /** + * インスタンスを生成する。 + * + */ + protected ProductInfoHolder() { + throw new JiemamyError("不到達ポイント"); + } + } + + + /** プロダクト名 */ + protected static final String PRODUCT_NAME = "Jiemamy EntityIO"; + + /** 不明な値 */ + protected static final String UNKNOWN = "unknown"; + + + /** + * シングルトンの{@link ProductInfo}を取得する。 + * + * @return シングルトンの{@link ProductInfo} + */ + public static ProductInfo getInstance() { + return ProductInfoHolder.PRODUCT_INFO; + } + + /** + * プロダクト情報を標準出力へ出力する。 + * + * @param args プログラム引数 + */ + public static void main(String[] args) { + ProductInfo info = ProductInfoHolder.PRODUCT_INFO; + System.out.printf("jiemamy entity io name : %s\n", info.getName()); + System.out.printf("jiemamy entity io version : %s\n", info.getVersion()); + System.out.printf("jiemamy entity io groupId : %s\n", info.getGroupId()); + System.out.printf("jiemamy entity io artifactId : %s\n", info.getArtifactId()); + } + + + /** groupId */ + protected final String groupId; + + /** artifactId */ + protected final String artifactId; + + /** バージョン */ + protected final String version; + + + /** + * インスタンスを生成する。 + * + * @param version バージョン + * @param groupId グループID + * @param artifactId アーティファクトID + */ + protected ProductInfo(String version, String groupId, String artifactId) { + this.version = version != null ? version : UNKNOWN; + this.groupId = groupId != null ? groupId : UNKNOWN; + this.artifactId = artifactId != null ? artifactId : UNKNOWN; + } + + /** + * artifactIdを取得する。 + * + * @return artifactId + */ + public String getArtifactId() { + return artifactId; + } + + /** + * groupIdを取得する。 + * + * @return groupId + */ + public String getGroupId() { + return groupId; + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return PRODUCT_NAME; + } + + /** + * バージョンを取得する。 + * + * @return バージョン + */ + public String getVersion() { + return version; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/ProductInfo.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/annotation/ColumnName.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/annotation/ColumnName.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/annotation/ColumnName.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,38 +1,38 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 10, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * カラム名用のアノテーション - * - * @author j5ik2o - */ - @ Retention(RetentionPolicy.RUNTIME) - @ Target(ElementType.FIELD) -public @interface ColumnName { - - /** 論理名 */ - String logical() default ""; - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 10, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * カラム名用のアノテーション + * + * @author j5ik2o + */ + @ Retention(RetentionPolicy.RUNTIME) + @ Target(ElementType.FIELD) +public @interface ColumnName { + + /** 論理名 */ + String logical() default ""; + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/annotation/ColumnName.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/annotation/TableName.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/annotation/TableName.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/annotation/TableName.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,38 +1,38 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 10, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * テーブル名用のアノテーション - * - * @author j5ik2o - */ - @ Retention(RetentionPolicy.RUNTIME) - @ Target(ElementType.TYPE) -public @interface TableName { - - /** 論理名 */ - String logical() default ""; - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 10, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * テーブル名用のアノテーション + * + * @author j5ik2o + */ + @ Retention(RetentionPolicy.RUNTIME) + @ Target(ElementType.TYPE) +public @interface TableName { + + /** 論理名 */ + String logical() default ""; + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/annotation/TableName.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/convensition/PersistenceConvention.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/convensition/PersistenceConvention.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/convensition/PersistenceConvention.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,75 +1,75 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 15, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.convensition; - -/** - * 永続化層の命名規約を表すインターフェース。 - * - * @author j5ik2o - */ -public interface PersistenceConvention { - - /** - * カラム名をプロパティ名に変換する。 - * - * @param columnName カラム名 - * @return プロパティ名 - */ - String fromColumnNameToPropertyName(String columnName); - - /** - * エンティティ名をテーブル名に変更する。 - * - * @param entityName エンティティ名 - * @return テーブル名 - */ - String fromEntityNameToTableName(String entityName); - - /** - * フィールド名をプロパティ名に変換する。 - * - * @param fieldName フィールド名 - * @return プロパティ名 - */ - String fromFieldNameToPropertyName(String fieldName); - - /** - * プロパティ名をカラム名に変換する。 - * - * @param propertyName プロパティ名 - * @return カラム名 - */ - String fromPropertyNameToColumnName(String propertyName); - - /** - * プロパティ名をフィールド名に変換する。 - * - * @param propertyName プロパティ名 - * @return フィールド名 - */ - String fromPropertyNameToFieldName(String propertyName); - - /** - * テーブル名をエンティティ名に変換する。 - * - * @param tableName テーブル名 - * @return エンティティ名 - */ - String fromTableNameToEntityName(String tableName); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 15, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.convensition; + +/** + * 永続化層の命名規約を表すインターフェース。 + * + * @author j5ik2o + */ +public interface PersistenceConvention { + + /** + * カラム名をプロパティ名に変換する。 + * + * @param columnName カラム名 + * @return プロパティ名 + */ + String fromColumnNameToPropertyName(String columnName); + + /** + * エンティティ名をテーブル名に変更する。 + * + * @param entityName エンティティ名 + * @return テーブル名 + */ + String fromEntityNameToTableName(String entityName); + + /** + * フィールド名をプロパティ名に変換する。 + * + * @param fieldName フィールド名 + * @return プロパティ名 + */ + String fromFieldNameToPropertyName(String fieldName); + + /** + * プロパティ名をカラム名に変換する。 + * + * @param propertyName プロパティ名 + * @return カラム名 + */ + String fromPropertyNameToColumnName(String propertyName); + + /** + * プロパティ名をフィールド名に変換する。 + * + * @param propertyName プロパティ名 + * @return フィールド名 + */ + String fromPropertyNameToFieldName(String propertyName); + + /** + * テーブル名をエンティティ名に変換する。 + * + * @param tableName テーブル名 + * @return エンティティ名 + */ + String fromTableNameToEntityName(String tableName); +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/convensition/PersistenceConvention.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/convensition/impl/PersistenceConventionImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/convensition/impl/PersistenceConventionImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/convensition/impl/PersistenceConventionImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,117 +1,117 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 15, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.convensition.impl; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.entity.io.convensition.PersistenceConvention; -import org.jiemamy.utils.StringUtil; - -/** - * {@link PersistenceConvention}の実装クラス。 - * - * @author j5ik2o - */ -public class PersistenceConventionImpl implements PersistenceConvention { - - private String ignoreTablePrefix; - - private boolean noNameConversion = false; - - - public String fromColumnNameToPropertyName(String columnName) { - Validate.notNull(columnName); - if (noNameConversion) { - return columnName; - } - return StringUtil.decapitalize(StringUtil.camelize(columnName)); - } - - public String fromEntityNameToTableName(String entityName) { - Validate.notNull(entityName); - if (noNameConversion) { - return entityName; - } - String tableName = StringUtil.decamelize(entityName); - if (ignoreTablePrefix != null) { - tableName = ignoreTablePrefix + tableName; - } - return tableName; - } - - public String fromFieldNameToPropertyName(String fieldName) { - return fieldName; - } - - public String fromPropertyNameToColumnName(String propertyName) { - Validate.notNull(propertyName); - if (noNameConversion) { - return propertyName; - } - return StringUtil.decamelize(propertyName); - } - - public String fromPropertyNameToFieldName(String propertyName) { - return propertyName; - } - - public String fromTableNameToEntityName(String tableName) { - Validate.notNull(tableName); - if (noNameConversion) { - return tableName; - } - return StringUtil.camelize(StringUtil.trimPrefix(tableName, ignoreTablePrefix)); - } - - /** - * 無視するテーブルの<code>prefix</code>を取得する。 - * - * @return 無視するテーブルの<code>prefix</code> - */ - public String getIgnoreTablePrefix() { - return ignoreTablePrefix; - } - - /** - * 名前を変換しないかどうかを返します。 - * - * @return 名前を変換しないかどうか - */ - public boolean isNoNameConversion() { - return noNameConversion; - } - - /** - * 無視するテーブルの<code>prefix</code>を設定します。 - * - * @param ignoreTablePrefix 無視するテーブルの<code>prefix</code> - */ - public void setIgnoreTablePrefix(String ignoreTablePrefix) { - this.ignoreTablePrefix = ignoreTablePrefix; - } - - /** - * 名前を変換しないかどうかを設定します。 - * - * @param noNameConversion trueの場合変換しない - */ - public void setNoNameConversion(boolean noNameConversion) { - this.noNameConversion = noNameConversion; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 15, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.convensition.impl; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.entity.io.convensition.PersistenceConvention; +import org.jiemamy.utils.StringUtil; + +/** + * {@link PersistenceConvention}の実装クラス。 + * + * @author j5ik2o + */ +public class PersistenceConventionImpl implements PersistenceConvention { + + private String ignoreTablePrefix; + + private boolean noNameConversion = false; + + + public String fromColumnNameToPropertyName(String columnName) { + Validate.notNull(columnName); + if (noNameConversion) { + return columnName; + } + return StringUtil.decapitalize(StringUtil.camelize(columnName)); + } + + public String fromEntityNameToTableName(String entityName) { + Validate.notNull(entityName); + if (noNameConversion) { + return entityName; + } + String tableName = StringUtil.decamelize(entityName); + if (ignoreTablePrefix != null) { + tableName = ignoreTablePrefix + tableName; + } + return tableName; + } + + public String fromFieldNameToPropertyName(String fieldName) { + return fieldName; + } + + public String fromPropertyNameToColumnName(String propertyName) { + Validate.notNull(propertyName); + if (noNameConversion) { + return propertyName; + } + return StringUtil.decamelize(propertyName); + } + + public String fromPropertyNameToFieldName(String propertyName) { + return propertyName; + } + + public String fromTableNameToEntityName(String tableName) { + Validate.notNull(tableName); + if (noNameConversion) { + return tableName; + } + return StringUtil.camelize(StringUtil.trimPrefix(tableName, ignoreTablePrefix)); + } + + /** + * 無視するテーブルの<code>prefix</code>を取得する。 + * + * @return 無視するテーブルの<code>prefix</code> + */ + public String getIgnoreTablePrefix() { + return ignoreTablePrefix; + } + + /** + * 名前を変換しないかどうかを返します。 + * + * @return 名前を変換しないかどうか + */ + public boolean isNoNameConversion() { + return noNameConversion; + } + + /** + * 無視するテーブルの<code>prefix</code>を設定します。 + * + * @param ignoreTablePrefix 無視するテーブルの<code>prefix</code> + */ + public void setIgnoreTablePrefix(String ignoreTablePrefix) { + this.ignoreTablePrefix = ignoreTablePrefix; + } + + /** + * 名前を変換しないかどうかを設定します。 + * + * @param noNameConversion trueの場合変換しない + */ + public void setNoNameConversion(boolean noNameConversion) { + this.noNameConversion = noNameConversion; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/convensition/impl/PersistenceConventionImpl.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AssociationDesc.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AssociationDesc.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AssociationDesc.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,222 +1,222 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * 関連記述インターフェイス。 - * - * @author j5ik2o - */ -public class AssociationDesc { - - /** 名前 */ - protected String name; - - /** 関連先のエンティティ記述 */ - protected EntityDesc referencedEntityDesc; - - /** 関連タイプ */ - protected AssociationType associationType; - - /** 関連の所有者側のプロパティの名前 */ - protected String mappedBy; - - /** カラム名のリスト */ - protected List<String> columnNameList = new ArrayList<String>(); - - /** 参照されるテーブルのカタログ名 */ - protected String referencedCatalogName; - - /** 参照されるテーブルのスキーマ名 */ - protected String referencedSchemaName; - - /** 参照されるテーブル名 */ - protected String referencedTableName; - - /** 参照されるカラム名のリスト */ - protected List<String> referencedColumnNameList = new ArrayList<String>(); - - - /** - * カラム名を追加する。 - * - * @param columnName カラム名 - */ - public void addColumnName(String columnName) { - columnNameList.add(columnName); - } - - /** - * 参照されるカラム名を追加する。 - * - * @param referencedColumnName 参照されるカラム名 - */ - public void addReferencedColumnName(String referencedColumnName) { - referencedColumnNameList.add(referencedColumnName); - } - - /** - * 関連タイプを取得する。 - * - * @return 関連タイプ - */ - public AssociationType getAssociationType() { - return associationType; - } - - /** - * カラム名のリストを取得する。 - * - * @return カラム名のリスト - */ - public List<String> getColumnNameList() { - return Collections.unmodifiableList(columnNameList); - } - - /** - * 関連の所有者側のプロパティの名前を取得する。 - * - * @return 関連の所有者側のプロパティの名前 - */ - public String getMappedBy() { - return mappedBy; - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return name; - } - - /** - * 参照されるテーブルのカタログ名を取得する。 - * - * @return 参照されるテーブルのカタログ名 - */ - public String getReferencedCatalogName() { - return referencedCatalogName; - } - - /** - * 参照されるカラム名のリストを取得する。 - * - * @return 参照されるカラム名のリスト - */ - public List<String> getReferencedColumnNameList() { - return Collections.unmodifiableList(referencedColumnNameList); - } - - /** - * 関連先のエンティティ記述を取得する。 - * - * @return 関連先のエンティティ記述 - */ - public EntityDesc getReferencedEntityDesc() { - return referencedEntityDesc; - } - - /** - * 参照されるテーブルのスキーマ名を取得する。 - * - * @return 参照されるテーブルのスキーマ名 - */ - public String getReferencedSchemaName() { - return referencedSchemaName; - } - - /** - * 参照されるテーブル名を取得する。 - * - * @return 参照されるテーブル名 - */ - public String getReferencedTableName() { - return referencedTableName; - } - - /** - * 関連タイプを設定する。 - * - * @param associationType 関連タイプ - */ - public void setAssociationType(AssociationType associationType) { - this.associationType = associationType; - } - - /** - * 関連の所有者側のプロパティの名前を設定する。 - * - * @param mappedBy 関連の所有者側のプロパティの名前 - */ - public void setMappedBy(String mappedBy) { - this.mappedBy = mappedBy; - } - - /** - * 名前を設定する。 - * - * @param name 名前 - */ - public void setName(String name) { - this.name = name; - } - - /** - * 参照されるテーブルのカタログ名を設定する。 - * - * @param referencedCatalogName 参照されるテーブルのカタログ名 - */ - public void setReferencedCatalogName(String referencedCatalogName) { - this.referencedCatalogName = referencedCatalogName; - } - - /** - * 関連先のエンティティ記述を設定する。 - * - * @param relationshipEntityDesc 関連先のエンティティ記述 - */ - public void setReferencedEntityDesc(EntityDesc relationshipEntityDesc) { - referencedEntityDesc = relationshipEntityDesc; - } - - /** - * 参照されるテーブルのスキーマ名を設定する。 - * - * @param referencedSchemaName 参照されるテーブルのスキーマ名 - */ - public void setReferencedSchemaName(String referencedSchemaName) { - this.referencedSchemaName = referencedSchemaName; - } - - /** - * 参照されるテーブル名を設定する。 - * - * @param referencedTableName 参照されるテーブル名 - */ - public void setReferencedTableName(String referencedTableName) { - this.referencedTableName = referencedTableName; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * 関連記述インターフェイス。 + * + * @author j5ik2o + */ +public class AssociationDesc { + + /** 名前 */ + protected String name; + + /** 関連先のエンティティ記述 */ + protected EntityDesc referencedEntityDesc; + + /** 関連タイプ */ + protected AssociationType associationType; + + /** 関連の所有者側のプロパティの名前 */ + protected String mappedBy; + + /** カラム名のリスト */ + protected List<String> columnNameList = new ArrayList<String>(); + + /** 参照されるテーブルのカタログ名 */ + protected String referencedCatalogName; + + /** 参照されるテーブルのスキーマ名 */ + protected String referencedSchemaName; + + /** 参照されるテーブル名 */ + protected String referencedTableName; + + /** 参照されるカラム名のリスト */ + protected List<String> referencedColumnNameList = new ArrayList<String>(); + + + /** + * カラム名を追加する。 + * + * @param columnName カラム名 + */ + public void addColumnName(String columnName) { + columnNameList.add(columnName); + } + + /** + * 参照されるカラム名を追加する。 + * + * @param referencedColumnName 参照されるカラム名 + */ + public void addReferencedColumnName(String referencedColumnName) { + referencedColumnNameList.add(referencedColumnName); + } + + /** + * 関連タイプを取得する。 + * + * @return 関連タイプ + */ + public AssociationType getAssociationType() { + return associationType; + } + + /** + * カラム名のリストを取得する。 + * + * @return カラム名のリスト + */ + public List<String> getColumnNameList() { + return Collections.unmodifiableList(columnNameList); + } + + /** + * 関連の所有者側のプロパティの名前を取得する。 + * + * @return 関連の所有者側のプロパティの名前 + */ + public String getMappedBy() { + return mappedBy; + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return name; + } + + /** + * 参照されるテーブルのカタログ名を取得する。 + * + * @return 参照されるテーブルのカタログ名 + */ + public String getReferencedCatalogName() { + return referencedCatalogName; + } + + /** + * 参照されるカラム名のリストを取得する。 + * + * @return 参照されるカラム名のリスト + */ + public List<String> getReferencedColumnNameList() { + return Collections.unmodifiableList(referencedColumnNameList); + } + + /** + * 関連先のエンティティ記述を取得する。 + * + * @return 関連先のエンティティ記述 + */ + public EntityDesc getReferencedEntityDesc() { + return referencedEntityDesc; + } + + /** + * 参照されるテーブルのスキーマ名を取得する。 + * + * @return 参照されるテーブルのスキーマ名 + */ + public String getReferencedSchemaName() { + return referencedSchemaName; + } + + /** + * 参照されるテーブル名を取得する。 + * + * @return 参照されるテーブル名 + */ + public String getReferencedTableName() { + return referencedTableName; + } + + /** + * 関連タイプを設定する。 + * + * @param associationType 関連タイプ + */ + public void setAssociationType(AssociationType associationType) { + this.associationType = associationType; + } + + /** + * 関連の所有者側のプロパティの名前を設定する。 + * + * @param mappedBy 関連の所有者側のプロパティの名前 + */ + public void setMappedBy(String mappedBy) { + this.mappedBy = mappedBy; + } + + /** + * 名前を設定する。 + * + * @param name 名前 + */ + public void setName(String name) { + this.name = name; + } + + /** + * 参照されるテーブルのカタログ名を設定する。 + * + * @param referencedCatalogName 参照されるテーブルのカタログ名 + */ + public void setReferencedCatalogName(String referencedCatalogName) { + this.referencedCatalogName = referencedCatalogName; + } + + /** + * 関連先のエンティティ記述を設定する。 + * + * @param relationshipEntityDesc 関連先のエンティティ記述 + */ + public void setReferencedEntityDesc(EntityDesc relationshipEntityDesc) { + referencedEntityDesc = relationshipEntityDesc; + } + + /** + * 参照されるテーブルのスキーマ名を設定する。 + * + * @param referencedSchemaName 参照されるテーブルのスキーマ名 + */ + public void setReferencedSchemaName(String referencedSchemaName) { + this.referencedSchemaName = referencedSchemaName; + } + + /** + * 参照されるテーブル名を設定する。 + * + * @param referencedTableName 参照されるテーブル名 + */ + public void setReferencedTableName(String referencedTableName) { + this.referencedTableName = referencedTableName; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AssociationDesc.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AssociationType.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AssociationType.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AssociationType.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,64 +1,64 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import java.lang.annotation.Annotation; - -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.OneToOne; - -/** - * 関連タイプ。 - * - * @author j5ik2o - */ -public enum AssociationType { - - /** - * 多対一です。 - */ - MANY_TO_ONE(ManyToOne.class), - - /** - * 一対多です。 - */ - ONE_TO_MANY(OneToMany.class), - - /** - * 一対一です。 - */ - ONE_TO_ONE(OneToOne.class); - - private final Class<? extends Annotation> annotation; - - - AssociationType(Class<? extends Annotation> annotation) { - this.annotation = annotation; - } - - /** - * アノテーションを取得する。 - * - * @return アノテーション - */ - public Class<? extends Annotation> getAnnotation() { - return annotation; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import java.lang.annotation.Annotation; + +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; + +/** + * 関連タイプ。 + * + * @author j5ik2o + */ +public enum AssociationType { + + /** + * 多対一です。 + */ + MANY_TO_ONE(ManyToOne.class), + + /** + * 一対多です。 + */ + ONE_TO_MANY(OneToMany.class), + + /** + * 一対一です。 + */ + ONE_TO_ONE(OneToOne.class); + + private final Class<? extends Annotation> annotation; + + + AssociationType(Class<? extends Annotation> annotation) { + this.annotation = annotation; + } + + /** + * アノテーションを取得する。 + * + * @return アノテーション + */ + public Class<? extends Annotation> getAnnotation() { + return annotation; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AssociationType.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AttributeDesc.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AttributeDesc.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AttributeDesc.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,464 +1,464 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import javax.persistence.GenerationType; -import javax.persistence.TemporalType; - -/** - * エンティティの属性記述インターフェイス。 - * - * @author j5ik2o - */ -public class AttributeDesc { - - /** 名前 */ - protected String name; - - /** 属性のクラス */ - protected Class<?> attributeClass; - - /** 識別子の場合{@code true} */ - protected boolean id; - - /** 識別子の生成方法を示す列挙型、生成しない場合{@code null} */ - protected GenerationType generationType; - - /** 識別子の初期値 */ - protected int initialValue; - - /** 識別子の割り当てサイズ */ - protected int allocationSize; - - /** バージョンの場合{@code true} */ - protected boolean version; - - /** 一時的の場合{@code true} */ - protected boolean trnsient; - - /** {@code LOB}の場合{@code true} */ - protected boolean lob; - - /** カラムの名前 */ - protected String columnName; - - /** 長さ */ - protected int length; - - /** 精度 */ - protected int precision; - - /** スケール */ - protected int scale; - - /** NULL可能の場合{@code true} */ - protected boolean nullable; - - /** 一意の場合{@code true} */ - protected boolean unique; - - /** カラム定義 */ - protected String columnDefinition; - - /** カラムの型名 */ - protected String columnTypeName; - - /** サポートされていないカラム型の場合{@code true} */ - protected boolean unsupportedColumnType; - - /** コメント */ - protected String comment; - - - /** - * インスタンスを生成する。 - */ - public AttributeDesc() { - } - - /** - * 識別子の割り当てサイズを取得する。 - * - * @return 識別子の割り当てサイズ - */ - public int getAllocationSize() { - return allocationSize; - } - - /** - * 属性のクラスを取得する。 - * - * @return 属性のクラス - */ - public Class<?> getAttributeClass() { - return attributeClass; - } - - /** - * カラム定義を取得する。 - * - * @return カラム定義 - */ - public String getColumnDefinition() { - return columnDefinition; - } - - /** - * カラムの名前を取得する。 - * - * @return カラムの名前 - */ - public String getColumnName() { - return columnName; - } - - /** - * カラムの型名を取得する。 - * - * @return カラムの型名 - */ - public String getColumnTypeName() { - return columnTypeName; - } - - /** - * コメントを取得する。 - * - * @return コメント - */ - public String getComment() { - return comment; - } - - /** - * 識別子の生成方法を示す列挙型を取得する。 - * - * @return 識別子の生成方法を示す列挙型、生成しない場合{@code null} - */ - public GenerationType getGenerationType() { - return generationType; - } - - /** - * 識別子の初期値を取得する。 - * - * @return 識別子の初期値 - */ - public int getInitialValue() { - return initialValue; - } - - /** - * 長さを取得する。 - * - * @return 長さ - */ - public int getLength() { - return length; - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return name; - } - - /** - * 精度を取得する。 - * - * @return 精度 - */ - public int getPrecision() { - return precision; - } - - /** - * スケールを取得する。 - * - * @return スケール - */ - public int getScale() { - return scale; - } - - /** - * 時制の種別を取得する。 - * - * @return 時制の種別、対応する種別がない場合{@code null} - */ - public TemporalType getTemporalType() { - if (attributeClass == java.sql.Date.class) { - return TemporalType.DATE; - } - if (attributeClass == java.sql.Time.class) { - return TemporalType.TIME; - } - if (attributeClass == java.sql.Timestamp.class) { - return TemporalType.TIMESTAMP; - } - return null; - } - - /** - * 識別子の場合{@code true}を取得する。 - * - * @return 識別子の場合{@code true}、そうでなければ{@code false} - */ - public boolean isId() { - return id; - } - - /** - * {@code LOB}の場合{@code true}を取得する。 - * - * @return {@code LOB}の場合{@code true}、そうでなければ{@code false} - */ - public boolean isLob() { - return lob; - } - - /** - * NULL可能の場合{@code true}を取得する。 - * - * @return NULL可能の場合{@code true}、そうでない場合{@code false} - */ - public boolean isNullable() { - return nullable; - } - - /** - * 時制を表す場合{@code true}を取得する。 - * - * @return 時制を表す場合{@code true} - */ - public boolean isTemporal() { - return getTemporalType() != null; - } - - /** - * 一時的の場合{@code true}を取得する。 - * - * @return 一時的の場合{@code true}、そうでなければ{@code false} - */ - public boolean isTransient() { - return trnsient; - } - - /** - * 一意の場合{@code true}、そうでない場合{@code false}を取得する。 - * - * @return 一意の場合{@code true}、そうでない場合{@code false} - */ - public boolean isUnique() { - return unique; - } - - /** - * サポートされていないカラム型の場合{@code true}を取得する。 - * - * @return サポートされていないカラム型の場合{@code true}、そうでない場合{@code false} - */ - public boolean isUnsupportedColumnType() { - return unsupportedColumnType; - } - - /** - * バージョンの場合{@code true}を取得する。 - * - * @return バージョンの場合{@code true}、そうでなければ{@code false} - */ - public boolean isVersion() { - return version; - } - - /** - * 識別子の割り当てサイズを設定する。 - * - * @param allocationSize 識別子の割り当てサイズ - */ - public void setAllocationSize(int allocationSize) { - this.allocationSize = allocationSize; - } - - /** - * 属性のクラスを設定する。 - * - * @param attributeClass 属性のクラス - */ - public void setAttributeClass(Class<?> attributeClass) { - this.attributeClass = attributeClass; - } - - /** - * カラム定義を設定する。 - * - * @param columnDefinition カラム定義 - */ - public void setColumnDefinition(String columnDefinition) { - this.columnDefinition = columnDefinition; - } - - /** - * カラムの名前を設定する。 - * - * @param columnName カラムの名前 - */ - public void setColumnName(String columnName) { - this.columnName = columnName; - } - - /** - * カラムの型名を設定する。 - * - * @param columnTypeName カラムの型名 - */ - public void setColumnTypeName(String columnTypeName) { - this.columnTypeName = columnTypeName; - } - - /** - * コメントを設定する。 - * - * @param comment コメント - */ - public void setComment(String comment) { - this.comment = comment; - } - - /** - * 識別子の生成方法を示す列挙型を設定する。 - * - * @param generationType 識別子の生成方法を示す列挙型、生成しない場合{@code null} - */ - public void setGenerationType(GenerationType generationType) { - this.generationType = generationType; - } - - /** - * 識別子の場合{@code true}を設定する。 - * - * @param id 識別子の場合{@code true} - */ - public void setId(boolean id) { - this.id = id; - } - - /** - * 識別子の初期値を設定する。 - * - * @param initialValue 識別子の初期値 - */ - public void setInitialValue(int initialValue) { - this.initialValue = initialValue; - } - - /** - * 長さを設定する。 - * - * @param length 長さ - */ - public void setLength(int length) { - this.length = length; - } - - /** - * {@code LOB}の場合{@code true}を設定する。 - * - * @param lob {@code LOB}の場合{@code true} - */ - public void setLob(boolean lob) { - this.lob = lob; - } - - /** - * 名前を設定する。 - * - * @param name 名前 - */ - public void setName(String name) { - this.name = name; - } - - /** - * NULL可能の場合{@code true}を設定する。 - * - * @param nullable NULL可能の場合{@code true} - */ - public void setNullable(boolean nullable) { - this.nullable = nullable; - } - - /** - * 精度を設定する。 - * - * @param precision 精度 - */ - public void setPrecision(int precision) { - this.precision = precision; - } - - /** - * スケールを設定する。 - * - * @param scale スケール - */ - public void setScale(int scale) { - this.scale = scale; - } - - /** - * 一時的の場合{@code true}を設定する。 - * - * @param trnsient 一時的の場合{@code true} - */ - public void setTransient(boolean trnsient) { - this.trnsient = trnsient; - } - - /** - * 一意の場合{@code true}、そうでない場合{@code false}を設定する。 - * - * @param unique 一意の場合{@code true} - */ - public void setUnique(boolean unique) { - this.unique = unique; - } - - /** - * サポートされていないカラム型の場合{@code true}を設定する。 - * - * @param unsupportedColumnType サポートされていないカラム型の場合{@code true}、そうでない場合{@code false} - */ - public void setUnsupportedColumnType(boolean unsupportedColumnType) { - this.unsupportedColumnType = unsupportedColumnType; - } - - /** - * バージョンの場合{@code true}を設定する。 - * - * @param version バージョンの場合{@code true} - */ - public void setVersion(boolean version) { - this.version = version; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import javax.persistence.GenerationType; +import javax.persistence.TemporalType; + +/** + * エンティティの属性記述インターフェイス。 + * + * @author j5ik2o + */ +public class AttributeDesc { + + /** 名前 */ + protected String name; + + /** 属性のクラス */ + protected Class<?> attributeClass; + + /** 識別子の場合{@code true} */ + protected boolean id; + + /** 識別子の生成方法を示す列挙型、生成しない場合{@code null} */ + protected GenerationType generationType; + + /** 識別子の初期値 */ + protected int initialValue; + + /** 識別子の割り当てサイズ */ + protected int allocationSize; + + /** バージョンの場合{@code true} */ + protected boolean version; + + /** 一時的の場合{@code true} */ + protected boolean trnsient; + + /** {@code LOB}の場合{@code true} */ + protected boolean lob; + + /** カラムの名前 */ + protected String columnName; + + /** 長さ */ + protected int length; + + /** 精度 */ + protected int precision; + + /** スケール */ + protected int scale; + + /** NULL可能の場合{@code true} */ + protected boolean nullable; + + /** 一意の場合{@code true} */ + protected boolean unique; + + /** カラム定義 */ + protected String columnDefinition; + + /** カラムの型名 */ + protected String columnTypeName; + + /** サポートされていないカラム型の場合{@code true} */ + protected boolean unsupportedColumnType; + + /** コメント */ + protected String comment; + + + /** + * インスタンスを生成する。 + */ + public AttributeDesc() { + } + + /** + * 識別子の割り当てサイズを取得する。 + * + * @return 識別子の割り当てサイズ + */ + public int getAllocationSize() { + return allocationSize; + } + + /** + * 属性のクラスを取得する。 + * + * @return 属性のクラス + */ + public Class<?> getAttributeClass() { + return attributeClass; + } + + /** + * カラム定義を取得する。 + * + * @return カラム定義 + */ + public String getColumnDefinition() { + return columnDefinition; + } + + /** + * カラムの名前を取得する。 + * + * @return カラムの名前 + */ + public String getColumnName() { + return columnName; + } + + /** + * カラムの型名を取得する。 + * + * @return カラムの型名 + */ + public String getColumnTypeName() { + return columnTypeName; + } + + /** + * コメントを取得する。 + * + * @return コメント + */ + public String getComment() { + return comment; + } + + /** + * 識別子の生成方法を示す列挙型を取得する。 + * + * @return 識別子の生成方法を示す列挙型、生成しない場合{@code null} + */ + public GenerationType getGenerationType() { + return generationType; + } + + /** + * 識別子の初期値を取得する。 + * + * @return 識別子の初期値 + */ + public int getInitialValue() { + return initialValue; + } + + /** + * 長さを取得する。 + * + * @return 長さ + */ + public int getLength() { + return length; + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return name; + } + + /** + * 精度を取得する。 + * + * @return 精度 + */ + public int getPrecision() { + return precision; + } + + /** + * スケールを取得する。 + * + * @return スケール + */ + public int getScale() { + return scale; + } + + /** + * 時制の種別を取得する。 + * + * @return 時制の種別、対応する種別がない場合{@code null} + */ + public TemporalType getTemporalType() { + if (attributeClass == java.sql.Date.class) { + return TemporalType.DATE; + } + if (attributeClass == java.sql.Time.class) { + return TemporalType.TIME; + } + if (attributeClass == java.sql.Timestamp.class) { + return TemporalType.TIMESTAMP; + } + return null; + } + + /** + * 識別子の場合{@code true}を取得する。 + * + * @return 識別子の場合{@code true}、そうでなければ{@code false} + */ + public boolean isId() { + return id; + } + + /** + * {@code LOB}の場合{@code true}を取得する。 + * + * @return {@code LOB}の場合{@code true}、そうでなければ{@code false} + */ + public boolean isLob() { + return lob; + } + + /** + * NULL可能の場合{@code true}を取得する。 + * + * @return NULL可能の場合{@code true}、そうでない場合{@code false} + */ + public boolean isNullable() { + return nullable; + } + + /** + * 時制を表す場合{@code true}を取得する。 + * + * @return 時制を表す場合{@code true} + */ + public boolean isTemporal() { + return getTemporalType() != null; + } + + /** + * 一時的の場合{@code true}を取得する。 + * + * @return 一時的の場合{@code true}、そうでなければ{@code false} + */ + public boolean isTransient() { + return trnsient; + } + + /** + * 一意の場合{@code true}、そうでない場合{@code false}を取得する。 + * + * @return 一意の場合{@code true}、そうでない場合{@code false} + */ + public boolean isUnique() { + return unique; + } + + /** + * サポートされていないカラム型の場合{@code true}を取得する。 + * + * @return サポートされていないカラム型の場合{@code true}、そうでない場合{@code false} + */ + public boolean isUnsupportedColumnType() { + return unsupportedColumnType; + } + + /** + * バージョンの場合{@code true}を取得する。 + * + * @return バージョンの場合{@code true}、そうでなければ{@code false} + */ + public boolean isVersion() { + return version; + } + + /** + * 識別子の割り当てサイズを設定する。 + * + * @param allocationSize 識別子の割り当てサイズ + */ + public void setAllocationSize(int allocationSize) { + this.allocationSize = allocationSize; + } + + /** + * 属性のクラスを設定する。 + * + * @param attributeClass 属性のクラス + */ + public void setAttributeClass(Class<?> attributeClass) { + this.attributeClass = attributeClass; + } + + /** + * カラム定義を設定する。 + * + * @param columnDefinition カラム定義 + */ + public void setColumnDefinition(String columnDefinition) { + this.columnDefinition = columnDefinition; + } + + /** + * カラムの名前を設定する。 + * + * @param columnName カラムの名前 + */ + public void setColumnName(String columnName) { + this.columnName = columnName; + } + + /** + * カラムの型名を設定する。 + * + * @param columnTypeName カラムの型名 + */ + public void setColumnTypeName(String columnTypeName) { + this.columnTypeName = columnTypeName; + } + + /** + * コメントを設定する。 + * + * @param comment コメント + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** + * 識別子の生成方法を示す列挙型を設定する。 + * + * @param generationType 識別子の生成方法を示す列挙型、生成しない場合{@code null} + */ + public void setGenerationType(GenerationType generationType) { + this.generationType = generationType; + } + + /** + * 識別子の場合{@code true}を設定する。 + * + * @param id 識別子の場合{@code true} + */ + public void setId(boolean id) { + this.id = id; + } + + /** + * 識別子の初期値を設定する。 + * + * @param initialValue 識別子の初期値 + */ + public void setInitialValue(int initialValue) { + this.initialValue = initialValue; + } + + /** + * 長さを設定する。 + * + * @param length 長さ + */ + public void setLength(int length) { + this.length = length; + } + + /** + * {@code LOB}の場合{@code true}を設定する。 + * + * @param lob {@code LOB}の場合{@code true} + */ + public void setLob(boolean lob) { + this.lob = lob; + } + + /** + * 名前を設定する。 + * + * @param name 名前 + */ + public void setName(String name) { + this.name = name; + } + + /** + * NULL可能の場合{@code true}を設定する。 + * + * @param nullable NULL可能の場合{@code true} + */ + public void setNullable(boolean nullable) { + this.nullable = nullable; + } + + /** + * 精度を設定する。 + * + * @param precision 精度 + */ + public void setPrecision(int precision) { + this.precision = precision; + } + + /** + * スケールを設定する。 + * + * @param scale スケール + */ + public void setScale(int scale) { + this.scale = scale; + } + + /** + * 一時的の場合{@code true}を設定する。 + * + * @param trnsient 一時的の場合{@code true} + */ + public void setTransient(boolean trnsient) { + this.trnsient = trnsient; + } + + /** + * 一意の場合{@code true}、そうでない場合{@code false}を設定する。 + * + * @param unique 一意の場合{@code true} + */ + public void setUnique(boolean unique) { + this.unique = unique; + } + + /** + * サポートされていないカラム型の場合{@code true}を設定する。 + * + * @param unsupportedColumnType サポートされていないカラム型の場合{@code true}、そうでない場合{@code false} + */ + public void setUnsupportedColumnType(boolean unsupportedColumnType) { + this.unsupportedColumnType = unsupportedColumnType; + } + + /** + * バージョンの場合{@code true}を設定する。 + * + * @param version バージョンの場合{@code true} + */ + public void setVersion(boolean version) { + this.version = version; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AttributeDesc.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AttributeDescFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AttributeDescFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AttributeDescFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,39 +1,39 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import org.jiemamy.entity.io.gen.meta.DbColumnMeta; -import org.jiemamy.entity.io.gen.meta.DbTableMeta; - -/** - * {@link AttributeDesc 属性記述}のファクトリインターフェイス。 - * - * @author j5ik2o - */ -public interface AttributeDescFactory { - - /** - * 属性記述を取得する。 - * - * @param tableMeta テーブルメタデータ - * @param columnMeta カラムメタデータ - * @return 属性記述 - */ - AttributeDesc getAttributeDesc(DbTableMeta tableMeta, DbColumnMeta columnMeta); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import org.jiemamy.entity.io.gen.meta.DbColumnMeta; +import org.jiemamy.entity.io.gen.meta.DbTableMeta; + +/** + * {@link AttributeDesc 属性記述}のファクトリインターフェイス。 + * + * @author j5ik2o + */ +public interface AttributeDescFactory { + + /** + * 属性記述を取得する。 + * + * @param tableMeta テーブルメタデータ + * @param columnMeta カラムメタデータ + * @return 属性記述 + */ + AttributeDesc getAttributeDesc(DbTableMeta tableMeta, DbColumnMeta columnMeta); +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/AttributeDescFactory.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/CompositeUniqueConstraintDesc.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/CompositeUniqueConstraintDesc.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/CompositeUniqueConstraintDesc.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,63 +1,63 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * 複合一意制約記述インターフェイス。 - * - * @author j5ik2o - */ -public class CompositeUniqueConstraintDesc { - - /** カラム名のリスト */ - protected List<String> columnNameList = new ArrayList<String>(); - - - /** - * カラム名を追加する。 - * - * @param columnName カラム名 - */ - public void addColumnName(String columnName) { - columnNameList.add(columnName); - } - - /** - * カラム名のリストを取得する。 - * - * @return カラム名のリスト - */ - public List<String> getColumnNameList() { - return Collections.unmodifiableList(columnNameList); - } - - /** - * 複合一意制約の場合{@code true}、そうでない場合{@code false}を取得する。 - * - * @return 複合一意制約の場合{@code true}、そうでない場合{@code false} - */ - public boolean isComposite() { - return columnNameList.size() > 1; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * 複合一意制約記述インターフェイス。 + * + * @author j5ik2o + */ +public class CompositeUniqueConstraintDesc { + + /** カラム名のリスト */ + protected List<String> columnNameList = new ArrayList<String>(); + + + /** + * カラム名を追加する。 + * + * @param columnName カラム名 + */ + public void addColumnName(String columnName) { + columnNameList.add(columnName); + } + + /** + * カラム名のリストを取得する。 + * + * @return カラム名のリスト + */ + public List<String> getColumnNameList() { + return Collections.unmodifiableList(columnNameList); + } + + /** + * 複合一意制約の場合{@code true}、そうでない場合{@code false}を取得する。 + * + * @return 複合一意制約の場合{@code true}、そうでない場合{@code false} + */ + public boolean isComposite() { + return columnNameList.size() > 1; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/CompositeUniqueConstraintDesc.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/CompositeUniqueConstraintDescFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/CompositeUniqueConstraintDescFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/CompositeUniqueConstraintDescFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,37 +1,37 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import org.jiemamy.entity.io.gen.meta.DbUniqueKeyMeta; - -/** - * {@link CompositeUniqueConstraintDesc}のファクトリインターフェイス。 - * - * @author j5ik2o - */ -public interface CompositeUniqueConstraintDescFactory { - - /** - * 一意制約記述を取得する。 - * - * @param uniqueKeyMeta 一意キーメタデータ - * @return 存在する場合は一意制約記述、存在しない場合は{@code null} - */ - CompositeUniqueConstraintDesc getCompositeUniqueConstraintDesc(DbUniqueKeyMeta uniqueKeyMeta); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import org.jiemamy.entity.io.gen.meta.DbUniqueKeyMeta; + +/** + * {@link CompositeUniqueConstraintDesc}のファクトリインターフェイス。 + * + * @author j5ik2o + */ +public interface CompositeUniqueConstraintDescFactory { + + /** + * 一意制約記述を取得する。 + * + * @param uniqueKeyMeta 一意キーメタデータ + * @return 存在する場合は一意制約記述、存在しない場合は{@code null} + */ + CompositeUniqueConstraintDesc getCompositeUniqueConstraintDesc(DbUniqueKeyMeta uniqueKeyMeta); +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/CompositeUniqueConstraintDescFactory.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescSetWriterContext.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescSetWriterContext.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescSetWriterContext.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,473 +1,473 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 14, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import java.io.File; -import java.util.regex.Pattern; - -import javax.persistence.GenerationType; - -import org.jiemamy.entity.io.convensition.PersistenceConvention; -import org.jiemamy.entity.io.gen.dialect.GenDialect; -import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; - -/** - * {@link EntityDescSetWriterContext}のデフォルト実装。 - * - * @author j5ik2o - */ -public class DefaultEntityDescSetWriterContext implements EntityDescSetWriterContext { - - private Integer allocationSize; - - private GenerationType idGenerationType; - - private Integer initialValue; - - private File javaSrcFileDestDir; - - private String entityPackageName; - - private String javaSrcFileEncoding; - - private boolean overwrite; - - private String rootPackageName; - - private boolean applyDbCommentToJava; - - private boolean useTemporalType; - - private boolean useAccessor; - - private boolean showTableName; - - private String schemaName; - - private Pattern tableNamePattern; - - private String templateFileEncoding; - - private File templateFilePrimaryDir; - - private String templateName; - - private Pattern versionColumnNamePattern; - - private boolean showCatalogName; - - private boolean showColumnDefinition; - - private Pattern ignoreTableNamePattern; - - private boolean showColumnName; - - private boolean showJoinColumn; - - private boolean showSchemaName; - - private Class<?> entitySuperClass; - - private GenDialect dialect; - - private PersistenceConvention persistenceConvention; - - private File pluralFormFile; - - private DbTableMetaReader dbTableMetaReader; - - - public Integer getAllocationSize() { - return allocationSize; - } - - public DbTableMetaReader getDbTableMetaReader() { - return dbTableMetaReader; - } - - public GenDialect getDialect() { - return dialect; - } - - public String getEntityPackageName() { - return entityPackageName; - } - - public Class<?> getEntitySuperClass() { - return entitySuperClass; - } - - public GenerationType getIdGenerationType() { - return idGenerationType; - } - - public Pattern getIgnoreTableNamePattern() { - return ignoreTableNamePattern; - } - - public Integer getInitialValue() { - return initialValue; - } - - public File getJavaSrcFileDestDir() { - return javaSrcFileDestDir; - } - - public String getJavaSrcFileEncoding() { - return javaSrcFileEncoding; - } - - public PersistenceConvention getPersistenceConvention() { - return persistenceConvention; - } - - public File getPluralFormFile() { - return pluralFormFile; - } - - public String getRootPackageName() { - return rootPackageName; - } - - public String getSchemaName() { - return schemaName; - } - - public Pattern getTableNamePattern() { - return tableNamePattern; - } - - public String getTemplateFileEncoding() { - return templateFileEncoding; - } - - public File getTemplateFilePrimaryDir() { - return templateFilePrimaryDir; - } - - public String getTemplateName() { - return templateName; - } - - public Pattern getVersionColumnNamePattern() { - return versionColumnNamePattern; - } - - public boolean isApplyDbCommentToJava() { - return applyDbCommentToJava; - } - - public boolean isOverwrite() { - return overwrite; - } - - public boolean isShowCatalogName() { - return showCatalogName; - } - - public boolean isShowColumnDefinition() { - return showColumnDefinition; - } - - public boolean isShowColumnName() { - return showColumnName; - } - - public boolean isShowJoinColumn() { - return showJoinColumn; - } - - public boolean isShowSchemaName() { - return showSchemaName; - } - - public boolean isShowTableName() { - return showTableName; - } - - public boolean isUseAccessor() { - return useAccessor; - } - - public boolean isUseTemporalType() { - return useTemporalType; - } - - /** - * 識別子の割り当てサイズを設定する。 - * - * @param allocationSize 識別子の割り当てサイズ - */ - public void setAllocationSize(Integer allocationSize) { - this.allocationSize = allocationSize; - } - - /** - * DB上のコメントをエンティティに適用するかどうかのフラグを設定する。 - * - * @param applyDbCommentToJava trueの場合適用する - */ - public void setApplyDbCommentToJava(boolean applyDbCommentToJava) { - this.applyDbCommentToJava = applyDbCommentToJava; - } - - /** - * {@link DbTableMetaReader}を設定する。 - * - * @param dbTableMetaReader {@link DbTableMetaReader} - */ - public void setDbTableMetaReader(DbTableMetaReader dbTableMetaReader) { - this.dbTableMetaReader = dbTableMetaReader; - } - - /** - * {@link GenDialect}を設定する。 - * - * @param dialect {@link GenDialect} - */ - public void setDialect(GenDialect dialect) { - this.dialect = dialect; - } - - /** - * エンティティクラスのパッケージ名を設定する。 - * - * @param entityPackageName エンティティクラスのパッケージ名 - */ - public void setEntityPackageName(String entityPackageName) { - this.entityPackageName = entityPackageName; - } - - /** - * エンティティクラスのスーパークラスを設定する。 - * - * @param entitySuperClass エンティティクラスのスーパークラス - */ - public void setEntitySuperClass(Class<?> entitySuperClass) { - this.entitySuperClass = entitySuperClass; - } - - /** - * 識別子を生成する方法を設定する。 - * - * @param idGenerationType {@link GenerationType} - */ - public void setIdGenerationType(GenerationType idGenerationType) { - this.idGenerationType = idGenerationType; - } - - /** - * 対象としないテーブル名の正規表現を設定する。 - * - * @param ignoreTableNamePattern 対象としないテーブル名の正規表現 - */ - public void setIgnoreTableNamePattern(Pattern ignoreTableNamePattern) { - this.ignoreTableNamePattern = ignoreTableNamePattern; - } - - /** - * 識別子の初期値を設定する。 - * - * @param initialValue 識別子の初期値 - */ - public void setInitialValue(Integer initialValue) { - this.initialValue = initialValue; - } - - /** - * Javaソースファイルの出力先ディレクトリを設定する。 - * - * @param javaSrcFileDestDir Javaソースファイルの出力先ディレクトリ - */ - public void setJavaSrcFileDestDir(File javaSrcFileDestDir) { - this.javaSrcFileDestDir = javaSrcFileDestDir; - } - - /** - * Javaファイルのエンコーディングを設定する。 - * - * @param javaSrcFileEncoding Javaファイルのエンコーディング - */ - public void setJavaSrcFileEncoding(String javaSrcFileEncoding) { - this.javaSrcFileEncoding = javaSrcFileEncoding; - } - - /** - * 上書きフラグを設定する。 - * - * @param overwrite 上書きする場合は{@code true}、しない場合は{@code false} - */ - public void setOverwrite(boolean overwrite) { - this.overwrite = overwrite; - } - - /** - * {@link PersistenceConvention}を設定する。 - * - * @param persistenceConvention {@link PersistenceConvention} - */ - public void setPersistenceConvention(PersistenceConvention persistenceConvention) { - this.persistenceConvention = persistenceConvention; - } - - /** - * OneToManyアノテーションの関連プロパティ名を複数形で作成する際に使用される辞書ファイルを設定する。 - * - * @param pluralFormFile 辞書ファイル - */ - public void setPluralFormFile(File pluralFormFile) { - this.pluralFormFile = pluralFormFile; - } - - /** - * ルートパッケージ名を設定する。 - * - * @param rootPackageName ルートパッケージ名 - */ - public void setRootPackageName(String rootPackageName) { - this.rootPackageName = rootPackageName; - } - - /** - * スキーマ名を設定する。 - * - * @param schemaName スキーマ名 - */ - public void setSchemaName(String schemaName) { - this.schemaName = schemaName; - } - - /** - * Tableアノテーションのcatalog属性にカタログ名を明記するかどうかのフラグを設定する。 - * - * @param showCatalogName trueの場合明記する - */ - public void setShowCatalogName(boolean showCatalogName) { - this.showCatalogName = showCatalogName; - } - - /** - * ColumnアノテーションのcolumnDefinition属性にカラム定義を明記するかどうかのフラグを設定する。 - * - * @param showColumnDefinition trueの場合明記する - */ - public void setShowColumnDefinition(boolean showColumnDefinition) { - this.showColumnDefinition = showColumnDefinition; - } - - /** - * Columnアノテーションのname属性にカラム名を明記するかどうかのフラグを設定する。 - * - * @param showColumnName trueの場合明記する - */ - public void setShowColumnName(boolean showColumnName) { - this.showColumnName = showColumnName; - } - - /** - * JoinColumnアノテーションを明記するかどうかのフラグを設定する。 - * - * @param showJoinColumn trueの場合明記する - */ - public void setShowJoinColumn(boolean showJoinColumn) { - this.showJoinColumn = showJoinColumn; - } - - /** - * Tableアノテーションのschema属性にスキーマ名を明記するかどうかのフラグを設定する。 - * - * @param showSchemaName trueの場合明記する - */ - public void setShowSchemaName(boolean showSchemaName) { - this.showSchemaName = showSchemaName; - } - - /** - * Tableアノテーションのname属性にテーブル名を明記するかどうかのフラグを設定する。 - * - * @param showTableName trueの場合明記する - */ - public void setShowTableName(boolean showTableName) { - this.showTableName = showTableName; - } - - /** - * 対象とするテーブル名の正規表現を設定する。 - * - * @param tableNamePattern 対象とするテーブル名の正規表現 - */ - public void setTableNamePattern(Pattern tableNamePattern) { - this.tableNamePattern = tableNamePattern; - } - - /** - * テンプレートファイルのエンコーディングを設定する。 - * - * @param templateFileEncoding テンプレートファイルのエンコーディング - */ - public void setTemplateFileEncoding(String templateFileEncoding) { - this.templateFileEncoding = templateFileEncoding; - } - - /** - * テンプレートファイルを検索する際の優先ディレクトリを設定する。 - * - * @param templateFilePrimaryDir テンプレートファイルを検索する際の優先ディレクトリ - */ - public void setTemplateFilePrimaryDir(File templateFilePrimaryDir) { - this.templateFilePrimaryDir = templateFilePrimaryDir; - } - - /** - * テンプレート名を設定する。 - * - * @param templateName テンプレート名 - */ - public void setTemplateName(String templateName) { - this.templateName = templateName; - } - - /** - * 生成するエンティティのアクセサメソッドを付与するかどうかのフラグを設定する。 - * - * @param useAccessor trueの場合付与する - */ - public void setUseAccessor(boolean useAccessor) { - this.useAccessor = useAccessor; - } - - /** - * 日付型カラムに対応するプロパティの型を@Temporalつきのjava.util.Dateとする。 - * - * @param useTemporalType trueの場合@Temporalつきのjava.util.Dateにする。 - */ - public void setUseTemporalType(boolean useTemporalType) { - this.useTemporalType = useTemporalType; - } - - /** - * エンティティのプロパティに@Versionを付与するカラム名の正規表現を設定する。 - * - * @param versionColumnNamePattern {@link Pattern} - */ - public void setVersionColumnNamePattern(Pattern versionColumnNamePattern) { - this.versionColumnNamePattern = versionColumnNamePattern; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 14, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import java.io.File; +import java.util.regex.Pattern; + +import javax.persistence.GenerationType; + +import org.jiemamy.entity.io.convensition.PersistenceConvention; +import org.jiemamy.entity.io.gen.dialect.GenDialect; +import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; + +/** + * {@link EntityDescSetWriterContext}のデフォルト実装。 + * + * @author j5ik2o + */ +public class DefaultEntityDescSetWriterContext implements EntityDescSetWriterContext { + + private Integer allocationSize; + + private GenerationType idGenerationType; + + private Integer initialValue; + + private File javaSrcFileDestDir; + + private String entityPackageName; + + private String javaSrcFileEncoding; + + private boolean overwrite; + + private String rootPackageName; + + private boolean applyDbCommentToJava; + + private boolean useTemporalType; + + private boolean useAccessor; + + private boolean showTableName; + + private String schemaName; + + private Pattern tableNamePattern; + + private String templateFileEncoding; + + private File templateFilePrimaryDir; + + private String templateName; + + private Pattern versionColumnNamePattern; + + private boolean showCatalogName; + + private boolean showColumnDefinition; + + private Pattern ignoreTableNamePattern; + + private boolean showColumnName; + + private boolean showJoinColumn; + + private boolean showSchemaName; + + private Class<?> entitySuperClass; + + private GenDialect dialect; + + private PersistenceConvention persistenceConvention; + + private File pluralFormFile; + + private DbTableMetaReader dbTableMetaReader; + + + public Integer getAllocationSize() { + return allocationSize; + } + + public DbTableMetaReader getDbTableMetaReader() { + return dbTableMetaReader; + } + + public GenDialect getDialect() { + return dialect; + } + + public String getEntityPackageName() { + return entityPackageName; + } + + public Class<?> getEntitySuperClass() { + return entitySuperClass; + } + + public GenerationType getIdGenerationType() { + return idGenerationType; + } + + public Pattern getIgnoreTableNamePattern() { + return ignoreTableNamePattern; + } + + public Integer getInitialValue() { + return initialValue; + } + + public File getJavaSrcFileDestDir() { + return javaSrcFileDestDir; + } + + public String getJavaSrcFileEncoding() { + return javaSrcFileEncoding; + } + + public PersistenceConvention getPersistenceConvention() { + return persistenceConvention; + } + + public File getPluralFormFile() { + return pluralFormFile; + } + + public String getRootPackageName() { + return rootPackageName; + } + + public String getSchemaName() { + return schemaName; + } + + public Pattern getTableNamePattern() { + return tableNamePattern; + } + + public String getTemplateFileEncoding() { + return templateFileEncoding; + } + + public File getTemplateFilePrimaryDir() { + return templateFilePrimaryDir; + } + + public String getTemplateName() { + return templateName; + } + + public Pattern getVersionColumnNamePattern() { + return versionColumnNamePattern; + } + + public boolean isApplyDbCommentToJava() { + return applyDbCommentToJava; + } + + public boolean isOverwrite() { + return overwrite; + } + + public boolean isShowCatalogName() { + return showCatalogName; + } + + public boolean isShowColumnDefinition() { + return showColumnDefinition; + } + + public boolean isShowColumnName() { + return showColumnName; + } + + public boolean isShowJoinColumn() { + return showJoinColumn; + } + + public boolean isShowSchemaName() { + return showSchemaName; + } + + public boolean isShowTableName() { + return showTableName; + } + + public boolean isUseAccessor() { + return useAccessor; + } + + public boolean isUseTemporalType() { + return useTemporalType; + } + + /** + * 識別子の割り当てサイズを設定する。 + * + * @param allocationSize 識別子の割り当てサイズ + */ + public void setAllocationSize(Integer allocationSize) { + this.allocationSize = allocationSize; + } + + /** + * DB上のコメントをエンティティに適用するかどうかのフラグを設定する。 + * + * @param applyDbCommentToJava trueの場合適用する + */ + public void setApplyDbCommentToJava(boolean applyDbCommentToJava) { + this.applyDbCommentToJava = applyDbCommentToJava; + } + + /** + * {@link DbTableMetaReader}を設定する。 + * + * @param dbTableMetaReader {@link DbTableMetaReader} + */ + public void setDbTableMetaReader(DbTableMetaReader dbTableMetaReader) { + this.dbTableMetaReader = dbTableMetaReader; + } + + /** + * {@link GenDialect}を設定する。 + * + * @param dialect {@link GenDialect} + */ + public void setDialect(GenDialect dialect) { + this.dialect = dialect; + } + + /** + * エンティティクラスのパッケージ名を設定する。 + * + * @param entityPackageName エンティティクラスのパッケージ名 + */ + public void setEntityPackageName(String entityPackageName) { + this.entityPackageName = entityPackageName; + } + + /** + * エンティティクラスのスーパークラスを設定する。 + * + * @param entitySuperClass エンティティクラスのスーパークラス + */ + public void setEntitySuperClass(Class<?> entitySuperClass) { + this.entitySuperClass = entitySuperClass; + } + + /** + * 識別子を生成する方法を設定する。 + * + * @param idGenerationType {@link GenerationType} + */ + public void setIdGenerationType(GenerationType idGenerationType) { + this.idGenerationType = idGenerationType; + } + + /** + * 対象としないテーブル名の正規表現を設定する。 + * + * @param ignoreTableNamePattern 対象としないテーブル名の正規表現 + */ + public void setIgnoreTableNamePattern(Pattern ignoreTableNamePattern) { + this.ignoreTableNamePattern = ignoreTableNamePattern; + } + + /** + * 識別子の初期値を設定する。 + * + * @param initialValue 識別子の初期値 + */ + public void setInitialValue(Integer initialValue) { + this.initialValue = initialValue; + } + + /** + * Javaソースファイルの出力先ディレクトリを設定する。 + * + * @param javaSrcFileDestDir Javaソースファイルの出力先ディレクトリ + */ + public void setJavaSrcFileDestDir(File javaSrcFileDestDir) { + this.javaSrcFileDestDir = javaSrcFileDestDir; + } + + /** + * Javaファイルのエンコーディングを設定する。 + * + * @param javaSrcFileEncoding Javaファイルのエンコーディング + */ + public void setJavaSrcFileEncoding(String javaSrcFileEncoding) { + this.javaSrcFileEncoding = javaSrcFileEncoding; + } + + /** + * 上書きフラグを設定する。 + * + * @param overwrite 上書きする場合は{@code true}、しない場合は{@code false} + */ + public void setOverwrite(boolean overwrite) { + this.overwrite = overwrite; + } + + /** + * {@link PersistenceConvention}を設定する。 + * + * @param persistenceConvention {@link PersistenceConvention} + */ + public void setPersistenceConvention(PersistenceConvention persistenceConvention) { + this.persistenceConvention = persistenceConvention; + } + + /** + * OneToManyアノテーションの関連プロパティ名を複数形で作成する際に使用される辞書ファイルを設定する。 + * + * @param pluralFormFile 辞書ファイル + */ + public void setPluralFormFile(File pluralFormFile) { + this.pluralFormFile = pluralFormFile; + } + + /** + * ルートパッケージ名を設定する。 + * + * @param rootPackageName ルートパッケージ名 + */ + public void setRootPackageName(String rootPackageName) { + this.rootPackageName = rootPackageName; + } + + /** + * スキーマ名を設定する。 + * + * @param schemaName スキーマ名 + */ + public void setSchemaName(String schemaName) { + this.schemaName = schemaName; + } + + /** + * Tableアノテーションのcatalog属性にカタログ名を明記するかどうかのフラグを設定する。 + * + * @param showCatalogName trueの場合明記する + */ + public void setShowCatalogName(boolean showCatalogName) { + this.showCatalogName = showCatalogName; + } + + /** + * ColumnアノテーションのcolumnDefinition属性にカラム定義を明記するかどうかのフラグを設定する。 + * + * @param showColumnDefinition trueの場合明記する + */ + public void setShowColumnDefinition(boolean showColumnDefinition) { + this.showColumnDefinition = showColumnDefinition; + } + + /** + * Columnアノテーションのname属性にカラム名を明記するかどうかのフラグを設定する。 + * + * @param showColumnName trueの場合明記する + */ + public void setShowColumnName(boolean showColumnName) { + this.showColumnName = showColumnName; + } + + /** + * JoinColumnアノテーションを明記するかどうかのフラグを設定する。 + * + * @param showJoinColumn trueの場合明記する + */ + public void setShowJoinColumn(boolean showJoinColumn) { + this.showJoinColumn = showJoinColumn; + } + + /** + * Tableアノテーションのschema属性にスキーマ名を明記するかどうかのフラグを設定する。 + * + * @param showSchemaName trueの場合明記する + */ + public void setShowSchemaName(boolean showSchemaName) { + this.showSchemaName = showSchemaName; + } + + /** + * Tableアノテーションのname属性にテーブル名を明記するかどうかのフラグを設定する。 + * + * @param showTableName trueの場合明記する + */ + public void setShowTableName(boolean showTableName) { + this.showTableName = showTableName; + } + + /** + * 対象とするテーブル名の正規表現を設定する。 + * + * @param tableNamePattern 対象とするテーブル名の正規表現 + */ + public void setTableNamePattern(Pattern tableNamePattern) { + this.tableNamePattern = tableNamePattern; + } + + /** + * テンプレートファイルのエンコーディングを設定する。 + * + * @param templateFileEncoding テンプレートファイルのエンコーディング + */ + public void setTemplateFileEncoding(String templateFileEncoding) { + this.templateFileEncoding = templateFileEncoding; + } + + /** + * テンプレートファイルを検索する際の優先ディレクトリを設定する。 + * + * @param templateFilePrimaryDir テンプレートファイルを検索する際の優先ディレクトリ + */ + public void setTemplateFilePrimaryDir(File templateFilePrimaryDir) { + this.templateFilePrimaryDir = templateFilePrimaryDir; + } + + /** + * テンプレート名を設定する。 + * + * @param templateName テンプレート名 + */ + public void setTemplateName(String templateName) { + this.templateName = templateName; + } + + /** + * 生成するエンティティのアクセサメソッドを付与するかどうかのフラグを設定する。 + * + * @param useAccessor trueの場合付与する + */ + public void setUseAccessor(boolean useAccessor) { + this.useAccessor = useAccessor; + } + + /** + * 日付型カラムに対応するプロパティの型を@Temporalつきのjava.util.Dateとする。 + * + * @param useTemporalType trueの場合@Temporalつきのjava.util.Dateにする。 + */ + public void setUseTemporalType(boolean useTemporalType) { + this.useTemporalType = useTemporalType; + } + + /** + * エンティティのプロパティに@Versionを付与するカラム名の正規表現を設定する。 + * + * @param versionColumnNamePattern {@link Pattern} + */ + public void setVersionColumnNamePattern(Pattern versionColumnNamePattern) { + this.versionColumnNamePattern = versionColumnNamePattern; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescSetWriterContext.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescSetWriterFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescSetWriterFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescSetWriterFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,41 +1,41 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import java.io.IOException; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.entity.io.gen.desc.impl.EntityDescSetWriterImpl; -import org.jiemamy.entity.io.gen.desc.impl.IdentityNotSupportedException; - -/** - * {@link EntityDescSetWriterFactory}の実装クラス。 - * - * @author j5ik2o - */ -public class DefaultEntityDescSetWriterFactory implements EntityDescSetWriterFactory { - - public EntityDescSetWriter createEntityDescSetWriter(EntityDescSetWriterContext entityDescSetWriterContext) - throws IdentityNotSupportedException, IOException { - Validate.notNull(entityDescSetWriterContext); - return new EntityDescSetWriterImpl(entityDescSetWriterContext); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import java.io.IOException; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.entity.io.gen.desc.impl.EntityDescSetWriterImpl; +import org.jiemamy.entity.io.gen.desc.impl.IdentityNotSupportedException; + +/** + * {@link EntityDescSetWriterFactory}の実装クラス。 + * + * @author j5ik2o + */ +public class DefaultEntityDescSetWriterFactory implements EntityDescSetWriterFactory { + + public EntityDescSetWriter createEntityDescSetWriter(EntityDescSetWriterContext entityDescSetWriterContext) + throws IdentityNotSupportedException, IOException { + Validate.notNull(entityDescSetWriterContext); + return new EntityDescSetWriterImpl(entityDescSetWriterContext); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescSetWriterFactory.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDesc.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDesc.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDesc.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,281 +1,281 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * エンティティ記述インターフェイス。 - * - * @author j5ik2o - */ -public class EntityDesc { - - /** 名前 */ - protected String name; - - /** カタログ名 */ - protected String catalogName; - - /** スキーマ名 */ - protected String schemaName; - - /** テーブル名 */ - protected String tableName; - - /** 複合識別子をもつならば{@code true} */ - protected boolean compositeId; - - /** コメント */ - protected String comment; - - /** 属性記述のリスト */ - protected List<AttributeDesc> attributeDescList = new ArrayList<AttributeDesc>(); - - /** 識別子である属性記述のリスト */ - protected List<AttributeDesc> idAttributeDescList = new ArrayList<AttributeDesc>(); - - /** 関連記述のリスト */ - protected List<AssociationDesc> associationDescList = new ArrayList<AssociationDesc>(); - - /** 一意制約記述のリスト */ - protected List<CompositeUniqueConstraintDesc> compositeUniqueConstraintDescList = - new ArrayList<CompositeUniqueConstraintDesc>(); - - - /** - * インスタンスを生成する。 - */ - public EntityDesc() { - } - - /** - * 関連記述を追加する。 - * - * @param associationDesc 関連記述 - */ - public void addAssociationDesc(AssociationDesc associationDesc) { - associationDescList.add(associationDesc); - } - - /** - * 属性記述を追加する。 - * - * @param attributeDesc 属性記述 - */ - public void addAttributeDesc(AttributeDesc attributeDesc) { - attributeDescList.add(attributeDesc); - if (attributeDesc.isId()) { - idAttributeDescList.add(attributeDesc); - } - } - - /** - * 複合一意制約記述を追加する。 - * - * @param compositeUniqueConstraintDesc 複合一意制約記述 - */ - public void addCompositeUniqueConstraintDesc(CompositeUniqueConstraintDesc compositeUniqueConstraintDesc) { - compositeUniqueConstraintDescList.add(compositeUniqueConstraintDesc); - } - - /** - * 関連記述のリストを取得する。 - * - * @return 関連記述のリスト - */ - public List<AssociationDesc> getAssociationDescList() { - return Collections.unmodifiableList(associationDescList); - } - - /** - * 属性記述のリストを取得する。 - * - * @return 属性記述のリスト - */ - public List<AttributeDesc> getAttributeDescList() { - return Collections.unmodifiableList(attributeDescList); - } - - /** - * カタログ名を取得する。 - * - * @return カタログ名 - */ - public String getCatalogName() { - return catalogName; - } - - /** - * コメントを取得する。 - * - * @return コメント - */ - public String getComment() { - return comment; - } - - /** - * 複合一意制約記述のリストを取得する。 - * - * @return 複合一意制約記述のリスト - */ - public List<CompositeUniqueConstraintDesc> getCompositeUniqueConstraintDescList() { - return Collections.unmodifiableList(compositeUniqueConstraintDescList); - } - - /** - * 完全なテーブル名を取得する。 - * - * @return 完全なテーブル名 - */ - public String getFullTableName() { - StringBuilder buf = new StringBuilder(); - if (catalogName != null) { - buf.append(catalogName).append("."); - } - if (schemaName != null) { - buf.append(schemaName).append("."); - } - return buf.append(tableName).toString(); - } - - /** - * 識別子である属性記述のリストを取得する。 - * - * @return 識別子である属性記述のリスト - */ - public List<AttributeDesc> getIdAttributeDescList() { - return Collections.unmodifiableList(idAttributeDescList); - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return name; - } - - /** - * スキーマ名を取得する。 - * - * @return スキーマ名 - */ - public String getSchemaName() { - return schemaName; - } - - /** - * テーブル名を取得する。 - * - * @return テーブル名 - */ - public String getTableName() { - return tableName; - } - - /** - * 指定された関連名の関連記述を持っている場合{@code true}を取得する。 - * - * @param associationName 関連名 - * @return 指定された関連名の関連記述を持っている場合{@code true}、そうでない場合{@code false} - */ - public boolean hasAssociationDesc(String associationName) { - for (AssociationDesc associationDesc : associationDescList) { - if (associationDesc.getName().equals(associationName)) { - return true; - } - } - return false; - } - - /** - * 指定された属性名の属性記述を持っている場合{@code true}を取得する。 - * - * @param attributeName 属性名 - * @return 指定された属性名の属性記述を持っている場合{@code true}、そうでない場合{@code false} - */ - public boolean hasAttributeDesc(String attributeName) { - for (AttributeDesc attributeDesc : attributeDescList) { - if (attributeDesc.getName().equals(attributeName)) { - return true; - } - } - return false; - } - - /** - * 複合識別子を持つならば{@code true}を取得する。 - * - * @return 複合識別子を持つならば{@code true}、そうでないならば{@code false} - */ - public boolean hasCompositeId() { - return idAttributeDescList.size() > 1; - } - - /** - * カタログ名を設定する。 - * - * @param catalogName カタログ名 - */ - public void setCatalogName(String catalogName) { - this.catalogName = catalogName; - } - - /** - * コメントを設定する。 - * - * @param comment コメント - */ - public void setComment(String comment) { - this.comment = comment; - } - - /** - * 名前を設定する。 - * - * @param name 名前 - */ - public void setName(String name) { - this.name = name; - } - - /** - * スキーマ名を設定する。 - * - * @param schemaName スキーマ名 - */ - public void setSchemaName(String schemaName) { - this.schemaName = schemaName; - } - - /** - * テーブル名を設定する。 - * - * @param tableName テーブル名 - */ - public void setTableName(String tableName) { - this.tableName = tableName; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * エンティティ記述インターフェイス。 + * + * @author j5ik2o + */ +public class EntityDesc { + + /** 名前 */ + protected String name; + + /** カタログ名 */ + protected String catalogName; + + /** スキーマ名 */ + protected String schemaName; + + /** テーブル名 */ + protected String tableName; + + /** 複合識別子をもつならば{@code true} */ + protected boolean compositeId; + + /** コメント */ + protected String comment; + + /** 属性記述のリスト */ + protected List<AttributeDesc> attributeDescList = new ArrayList<AttributeDesc>(); + + /** 識別子である属性記述のリスト */ + protected List<AttributeDesc> idAttributeDescList = new ArrayList<AttributeDesc>(); + + /** 関連記述のリスト */ + protected List<AssociationDesc> associationDescList = new ArrayList<AssociationDesc>(); + + /** 一意制約記述のリスト */ + protected List<CompositeUniqueConstraintDesc> compositeUniqueConstraintDescList = + new ArrayList<CompositeUniqueConstraintDesc>(); + + + /** + * インスタンスを生成する。 + */ + public EntityDesc() { + } + + /** + * 関連記述を追加する。 + * + * @param associationDesc 関連記述 + */ + public void addAssociationDesc(AssociationDesc associationDesc) { + associationDescList.add(associationDesc); + } + + /** + * 属性記述を追加する。 + * + * @param attributeDesc 属性記述 + */ + public void addAttributeDesc(AttributeDesc attributeDesc) { + attributeDescList.add(attributeDesc); + if (attributeDesc.isId()) { + idAttributeDescList.add(attributeDesc); + } + } + + /** + * 複合一意制約記述を追加する。 + * + * @param compositeUniqueConstraintDesc 複合一意制約記述 + */ + public void addCompositeUniqueConstraintDesc(CompositeUniqueConstraintDesc compositeUniqueConstraintDesc) { + compositeUniqueConstraintDescList.add(compositeUniqueConstraintDesc); + } + + /** + * 関連記述のリストを取得する。 + * + * @return 関連記述のリスト + */ + public List<AssociationDesc> getAssociationDescList() { + return Collections.unmodifiableList(associationDescList); + } + + /** + * 属性記述のリストを取得する。 + * + * @return 属性記述のリスト + */ + public List<AttributeDesc> getAttributeDescList() { + return Collections.unmodifiableList(attributeDescList); + } + + /** + * カタログ名を取得する。 + * + * @return カタログ名 + */ + public String getCatalogName() { + return catalogName; + } + + /** + * コメントを取得する。 + * + * @return コメント + */ + public String getComment() { + return comment; + } + + /** + * 複合一意制約記述のリストを取得する。 + * + * @return 複合一意制約記述のリスト + */ + public List<CompositeUniqueConstraintDesc> getCompositeUniqueConstraintDescList() { + return Collections.unmodifiableList(compositeUniqueConstraintDescList); + } + + /** + * 完全なテーブル名を取得する。 + * + * @return 完全なテーブル名 + */ + public String getFullTableName() { + StringBuilder buf = new StringBuilder(); + if (catalogName != null) { + buf.append(catalogName).append("."); + } + if (schemaName != null) { + buf.append(schemaName).append("."); + } + return buf.append(tableName).toString(); + } + + /** + * 識別子である属性記述のリストを取得する。 + * + * @return 識別子である属性記述のリスト + */ + public List<AttributeDesc> getIdAttributeDescList() { + return Collections.unmodifiableList(idAttributeDescList); + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return name; + } + + /** + * スキーマ名を取得する。 + * + * @return スキーマ名 + */ + public String getSchemaName() { + return schemaName; + } + + /** + * テーブル名を取得する。 + * + * @return テーブル名 + */ + public String getTableName() { + return tableName; + } + + /** + * 指定された関連名の関連記述を持っている場合{@code true}を取得する。 + * + * @param associationName 関連名 + * @return 指定された関連名の関連記述を持っている場合{@code true}、そうでない場合{@code false} + */ + public boolean hasAssociationDesc(String associationName) { + for (AssociationDesc associationDesc : associationDescList) { + if (associationDesc.getName().equals(associationName)) { + return true; + } + } + return false; + } + + /** + * 指定された属性名の属性記述を持っている場合{@code true}を取得する。 + * + * @param attributeName 属性名 + * @return 指定された属性名の属性記述を持っている場合{@code true}、そうでない場合{@code false} + */ + public boolean hasAttributeDesc(String attributeName) { + for (AttributeDesc attributeDesc : attributeDescList) { + if (attributeDesc.getName().equals(attributeName)) { + return true; + } + } + return false; + } + + /** + * 複合識別子を持つならば{@code true}を取得する。 + * + * @return 複合識別子を持つならば{@code true}、そうでないならば{@code false} + */ + public boolean hasCompositeId() { + return idAttributeDescList.size() > 1; + } + + /** + * カタログ名を設定する。 + * + * @param catalogName カタログ名 + */ + public void setCatalogName(String catalogName) { + this.catalogName = catalogName; + } + + /** + * コメントを設定する。 + * + * @param comment コメント + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** + * 名前を設定する。 + * + * @param name 名前 + */ + public void setName(String name) { + this.name = name; + } + + /** + * スキーマ名を設定する。 + * + * @param schemaName スキーマ名 + */ + public void setSchemaName(String schemaName) { + this.schemaName = schemaName; + } + + /** + * テーブル名を設定する。 + * + * @param tableName テーブル名 + */ + public void setTableName(String tableName) { + this.tableName = tableName; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDesc.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,37 +1,37 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import org.jiemamy.entity.io.gen.meta.DbTableMeta; - -/** - * {@link EntityDesc}のファクトリインターフェイス。 - * - * @author j5ik2o - */ -public interface EntityDescFactory { - - /** - * エンティティ記述を取得する。 - * - * @param tableMeta テーブルメタデータ - * @return エンティティ記述 - */ - EntityDesc getEntityDesc(DbTableMeta tableMeta); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import org.jiemamy.entity.io.gen.meta.DbTableMeta; + +/** + * {@link EntityDesc}のファクトリインターフェイス。 + * + * @author j5ik2o + */ +public interface EntityDescFactory { + + /** + * エンティティ記述を取得する。 + * + * @param tableMeta テーブルメタデータ + * @return エンティティ記述 + */ + EntityDesc getEntityDesc(DbTableMeta tableMeta); +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescFactory.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriter.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriter.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriter.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,39 +1,39 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import java.io.IOException; - -import org.jiemamy.entity.io.meta.EntityMeta; - -/** - * {@link EntityMeta エンティティメタデータ}を書き込むインタフェース。 - * - * @author j5ik2o - */ -public interface EntityDescSetWriter { - - /** - * エンティティメタデータを書き込む。 - * - * @throws IOException 入出力が失敗した場合 - */ - void write() throws IOException; - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import java.io.IOException; + +import org.jiemamy.entity.io.meta.EntityMeta; + +/** + * {@link EntityMeta エンティティメタデータ}を書き込むインタフェース。 + * + * @author j5ik2o + */ +public interface EntityDescSetWriter { + + /** + * エンティティメタデータを書き込む。 + * + * @throws IOException 入出力が失敗した場合 + */ + void write() throws IOException; + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriter.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriterContext.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriterContext.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriterContext.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,240 +1,240 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import java.io.File; -import java.util.regex.Pattern; - -import javax.persistence.GenerationType; - -import org.jiemamy.entity.io.convensition.PersistenceConvention; -import org.jiemamy.entity.io.gen.dialect.GenDialect; -import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; - -/** - * {@link EntityDescSetWriter}のコンテキストインターフェイス。 - * - * @author j5ik2o - */ -public interface EntityDescSetWriterContext { - - /** - * 識別子の割り当てサイズを取得する。 - * - * @return 識別子の割り当てサイズ - */ - Integer getAllocationSize(); - - /** - * {@link DbTableMetaReader}を取得する。 - * - * @return {@link DbTableMetaReader} - */ - DbTableMetaReader getDbTableMetaReader(); - - /** - * {@link GenDialect}を取得する。 - * - * @return {@link GenDialect} - */ - GenDialect getDialect(); - - /** - * エンティティクラスのパッケージ名を取得する。 - * - * @return エンティティクラス - */ - String getEntityPackageName(); - - /** - * エンティティクラスのスーパークラスを取得する。 - * - * @return エンティティクラス - */ - Class<?> getEntitySuperClass(); - - /** - * 識別子を生成する方法を取得する。 - * - * @return {@link GenerationType} - */ - GenerationType getIdGenerationType(); - - /** - * 対象としないテーブル名の正規表現を取得する。 - * - * @return {@link Pattern} - */ - Pattern getIgnoreTableNamePattern(); - - /** - * 識別子の初期値を取得する。 - * - * @return 識別子の初期値 - */ - Integer getInitialValue(); - - /** - * Javaソースファイルの出力先ディレクトリを取得する。 - * - * @return Javaソースファイルの出力先ディレクトリ - */ - File getJavaSrcFileDestDir(); - - /** - * Javaファイルのエンコーディングを取得する。 - * - * @return Javaファイルのエンコーディング - */ - String getJavaSrcFileEncoding(); - - /** - * {@link PersistenceConvention}を取得する。 - * - * @return {@link PersistenceConvention} - */ - PersistenceConvention getPersistenceConvention(); - - /** - * OneToManyアノテーションの関連プロパティ名を複数形で作成する際に使用される辞書ファイルを取得する。 - * - * @return 辞書ファイル - */ - File getPluralFormFile(); - - /** - * ルートパッケージ名を取得する。 - * - * @return パッケージ名 - */ - String getRootPackageName(); - - /** - * スキーマ名を取得する。 - * - * @return スキーマ名 - */ - String getSchemaName(); - - /** - * 対象とするテーブル名の正規表現を取得する。 - * - * @return {@link Pattern} - */ - Pattern getTableNamePattern(); - - /** - * テンプレートファイルのエンコーディングを取得する。 - * - * @return テンプレートファイルのエンコーディング - */ - String getTemplateFileEncoding(); - - /** - * テンプレートファイルを検索する際の優先ディレクトリを取得する。 - * - * @return テンプレートファイルを検索する際の優先ディレクトリ - */ - File getTemplateFilePrimaryDir(); - - /** - * テンプレート名を取得する。 - * - * @return テンプレート名 - */ - String getTemplateName(); - - /** - * エンティティのプロパティに@Versionを付与するカラム名の正規表現を取得する。 - * - * @return {@link Pattern} - */ - Pattern getVersionColumnNamePattern(); - - /** - * DB上のコメントをエンティティに適用するかどうかのフラグを取得する。 - * - * @return trueの場合適用する - */ - boolean isApplyDbCommentToJava(); - - /** - * 上書きフラグを取得する。 - * - * @return 上書きする場合は{@code true}、しない場合は{@code false} - */ - boolean isOverwrite(); - - /** - * Tableアノテーションのcatalog属性にカタログ名を明記するかどうかのフラグを取得する。 - * - * @return trueの場合明記する - */ - boolean isShowCatalogName(); - - /** - * ColumnアノテーションのcolumnDefinition属性にカラム定義を明記するかどうかのフラグを取得する。 - * - * @return trueの場合明記する - */ - boolean isShowColumnDefinition(); - - /** - * Columnアノテーションのname属性にカラム名を明記するかどうかのフラグを取得する。 - * - * @return trueの場合明記する - */ - boolean isShowColumnName(); - - /** - * JoinColumnアノテーションを明記するかどうかのフラグを取得する。 - * - * @return trueの場合明記する - */ - boolean isShowJoinColumn(); - - /** - * Tableアノテーションのschema属性にスキーマ名を明記するかどうかのフラグを取得する。 - * - * @return trueの場合明記する - */ - boolean isShowSchemaName(); - - /** - * Tableアノテーションのname属性にテーブル名を明記するかどうかのフラグを取得する。 - * - * @return trueの場合明記する - */ - boolean isShowTableName(); - - /** - * 生成するエンティティのアクセサメソッドを付与するかどうかのフラグを取得する。 - * - * @return trueの場合 - */ - boolean isUseAccessor(); - - /** - * 日付型カラムに対応するプロパティの型を@Temporalつきのjava.util.Dateとする。 - * - * @return trueの場合@Temporalつきのjava.util.Dateにする。 - */ - boolean isUseTemporalType(); - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import java.io.File; +import java.util.regex.Pattern; + +import javax.persistence.GenerationType; + +import org.jiemamy.entity.io.convensition.PersistenceConvention; +import org.jiemamy.entity.io.gen.dialect.GenDialect; +import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; + +/** + * {@link EntityDescSetWriter}のコンテキストインターフェイス。 + * + * @author j5ik2o + */ +public interface EntityDescSetWriterContext { + + /** + * 識別子の割り当てサイズを取得する。 + * + * @return 識別子の割り当てサイズ + */ + Integer getAllocationSize(); + + /** + * {@link DbTableMetaReader}を取得する。 + * + * @return {@link DbTableMetaReader} + */ + DbTableMetaReader getDbTableMetaReader(); + + /** + * {@link GenDialect}を取得する。 + * + * @return {@link GenDialect} + */ + GenDialect getDialect(); + + /** + * エンティティクラスのパッケージ名を取得する。 + * + * @return エンティティクラス + */ + String getEntityPackageName(); + + /** + * エンティティクラスのスーパークラスを取得する。 + * + * @return エンティティクラス + */ + Class<?> getEntitySuperClass(); + + /** + * 識別子を生成する方法を取得する。 + * + * @return {@link GenerationType} + */ + GenerationType getIdGenerationType(); + + /** + * 対象としないテーブル名の正規表現を取得する。 + * + * @return {@link Pattern} + */ + Pattern getIgnoreTableNamePattern(); + + /** + * 識別子の初期値を取得する。 + * + * @return 識別子の初期値 + */ + Integer getInitialValue(); + + /** + * Javaソースファイルの出力先ディレクトリを取得する。 + * + * @return Javaソースファイルの出力先ディレクトリ + */ + File getJavaSrcFileDestDir(); + + /** + * Javaファイルのエンコーディングを取得する。 + * + * @return Javaファイルのエンコーディング + */ + String getJavaSrcFileEncoding(); + + /** + * {@link PersistenceConvention}を取得する。 + * + * @return {@link PersistenceConvention} + */ + PersistenceConvention getPersistenceConvention(); + + /** + * OneToManyアノテーションの関連プロパティ名を複数形で作成する際に使用される辞書ファイルを取得する。 + * + * @return 辞書ファイル + */ + File getPluralFormFile(); + + /** + * ルートパッケージ名を取得する。 + * + * @return パッケージ名 + */ + String getRootPackageName(); + + /** + * スキーマ名を取得する。 + * + * @return スキーマ名 + */ + String getSchemaName(); + + /** + * 対象とするテーブル名の正規表現を取得する。 + * + * @return {@link Pattern} + */ + Pattern getTableNamePattern(); + + /** + * テンプレートファイルのエンコーディングを取得する。 + * + * @return テンプレートファイルのエンコーディング + */ + String getTemplateFileEncoding(); + + /** + * テンプレートファイルを検索する際の優先ディレクトリを取得する。 + * + * @return テンプレートファイルを検索する際の優先ディレクトリ + */ + File getTemplateFilePrimaryDir(); + + /** + * テンプレート名を取得する。 + * + * @return テンプレート名 + */ + String getTemplateName(); + + /** + * エンティティのプロパティに@Versionを付与するカラム名の正規表現を取得する。 + * + * @return {@link Pattern} + */ + Pattern getVersionColumnNamePattern(); + + /** + * DB上のコメントをエンティティに適用するかどうかのフラグを取得する。 + * + * @return trueの場合適用する + */ + boolean isApplyDbCommentToJava(); + + /** + * 上書きフラグを取得する。 + * + * @return 上書きする場合は{@code true}、しない場合は{@code false} + */ + boolean isOverwrite(); + + /** + * Tableアノテーションのcatalog属性にカタログ名を明記するかどうかのフラグを取得する。 + * + * @return trueの場合明記する + */ + boolean isShowCatalogName(); + + /** + * ColumnアノテーションのcolumnDefinition属性にカラム定義を明記するかどうかのフラグを取得する。 + * + * @return trueの場合明記する + */ + boolean isShowColumnDefinition(); + + /** + * Columnアノテーションのname属性にカラム名を明記するかどうかのフラグを取得する。 + * + * @return trueの場合明記する + */ + boolean isShowColumnName(); + + /** + * JoinColumnアノテーションを明記するかどうかのフラグを取得する。 + * + * @return trueの場合明記する + */ + boolean isShowJoinColumn(); + + /** + * Tableアノテーションのschema属性にスキーマ名を明記するかどうかのフラグを取得する。 + * + * @return trueの場合明記する + */ + boolean isShowSchemaName(); + + /** + * Tableアノテーションのname属性にテーブル名を明記するかどうかのフラグを取得する。 + * + * @return trueの場合明記する + */ + boolean isShowTableName(); + + /** + * 生成するエンティティのアクセサメソッドを付与するかどうかのフラグを取得する。 + * + * @return trueの場合 + */ + boolean isUseAccessor(); + + /** + * 日付型カラムに対応するプロパティの型を@Temporalつきのjava.util.Dateとする。 + * + * @return trueの場合@Temporalつきのjava.util.Dateにする。 + */ + boolean isUseTemporalType(); + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriterContext.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriterFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriterFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriterFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,42 +1,42 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import java.io.IOException; - -import org.jiemamy.entity.io.gen.desc.impl.IdentityNotSupportedException; - -/** - * {@link EntityDescSetWriter}用のファクトリインターフェイス。 - * - * @author j5ik2o - */ -public interface EntityDescSetWriterFactory { - - /** - * {@link EntityDescSetWriter}を生成する。 - * - * @param entityDescSetWriterContext {@link EntityDescSetWriterContext} - * @return {@link EntityDescSetWriter} - * @throws IdentityNotSupportedException - * @throws IOException - */ - EntityDescSetWriter createEntityDescSetWriter(EntityDescSetWriterContext entityDescSetWriterContext) - throws IdentityNotSupportedException, IOException; -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import java.io.IOException; + +import org.jiemamy.entity.io.gen.desc.impl.IdentityNotSupportedException; + +/** + * {@link EntityDescSetWriter}用のファクトリインターフェイス。 + * + * @author j5ik2o + */ +public interface EntityDescSetWriterFactory { + + /** + * {@link EntityDescSetWriter}を生成する。 + * + * @param entityDescSetWriterContext {@link EntityDescSetWriterContext} + * @return {@link EntityDescSetWriter} + * @throws IdentityNotSupportedException + * @throws IOException + */ + EntityDescSetWriter createEntityDescSetWriter(EntityDescSetWriterContext entityDescSetWriterContext) + throws IdentityNotSupportedException, IOException; +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescSetWriterFactory.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntitySetDesc.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntitySetDesc.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntitySetDesc.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,71 +1,71 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.jiemamy.utils.ArrayMap; - -/** - * エンティティ集合記述インターフェイス。 - * - * @author j5ik2o - */ -public class EntitySetDesc { - - /** エンティティ記述のリスト */ - protected List<EntityDesc> entityDescList = new ArrayList<EntityDesc>(); - - /** 完全なテーブル名をキー、エンティティ記述を値とするマップ */ - protected Map<String, EntityDesc> entityDescMap = new ArrayMap<String, EntityDesc>(); - - - /** - * エンティティ記述を追加する。 - * - * @param entityDesc エンティティ記述 - */ - public void addEntityDesc(EntityDesc entityDesc) { - entityDescList.add(entityDesc); - entityDescMap.put(entityDesc.getFullTableName(), entityDesc); - } - - /** - * 完全なテーブル名に対応するエンティティ記述を取得する。 - * - * @param fullTableName 完全なテーブル名 - * @return エンティティ記述、存在しない場合{@code null} - */ - public EntityDesc getEntityDesc(String fullTableName) { - return entityDescMap.get(fullTableName); - } - - /** - * エンティティ記述のリストを取得する。 - * - * @return エンティティ記述のリスト - */ - public List<EntityDesc> getEntityDescList() { - return Collections.unmodifiableList(entityDescList); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.jiemamy.utils.ArrayMap; + +/** + * エンティティ集合記述インターフェイス。 + * + * @author j5ik2o + */ +public class EntitySetDesc { + + /** エンティティ記述のリスト */ + protected List<EntityDesc> entityDescList = new ArrayList<EntityDesc>(); + + /** 完全なテーブル名をキー、エンティティ記述を値とするマップ */ + protected Map<String, EntityDesc> entityDescMap = new ArrayMap<String, EntityDesc>(); + + + /** + * エンティティ記述を追加する。 + * + * @param entityDesc エンティティ記述 + */ + public void addEntityDesc(EntityDesc entityDesc) { + entityDescList.add(entityDesc); + entityDescMap.put(entityDesc.getFullTableName(), entityDesc); + } + + /** + * 完全なテーブル名に対応するエンティティ記述を取得する。 + * + * @param fullTableName 完全なテーブル名 + * @return エンティティ記述、存在しない場合{@code null} + */ + public EntityDesc getEntityDesc(String fullTableName) { + return entityDescMap.get(fullTableName); + } + + /** + * エンティティ記述のリストを取得する。 + * + * @return エンティティ記述のリスト + */ + public List<EntityDesc> getEntityDescList() { + return Collections.unmodifiableList(entityDescList); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntitySetDesc.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntitySetDescFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntitySetDescFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntitySetDescFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,37 +1,37 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc; - -import java.io.IOException; - -/** - * {@link EntitySetDesc}のファクトリインターフェイス。 - * - * @author j5ik2o - */ -public interface EntitySetDescFactory { - - /** - * エンティティ集合記述を取得する。 - * - * @return エンティティ集合記述 - * @throws IOException 入出力が失敗した場合 - */ - EntitySetDesc getEntitySetDesc() throws IOException; -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc; + +import java.io.IOException; + +/** + * {@link EntitySetDesc}のファクトリインターフェイス。 + * + * @author j5ik2o + */ +public interface EntitySetDescFactory { + + /** + * エンティティ集合記述を取得する。 + * + * @return エンティティ集合記述 + * @throws IOException 入出力が失敗した場合 + */ + EntitySetDesc getEntitySetDesc() throws IOException; +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntitySetDescFactory.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/AssociationResolver.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/AssociationResolver.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/AssociationResolver.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,265 +1,265 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc.impl; - -import org.jiemamy.entity.io.gen.desc.AssociationDesc; -import org.jiemamy.entity.io.gen.desc.AssociationType; -import org.jiemamy.entity.io.gen.desc.AttributeDesc; -import org.jiemamy.entity.io.gen.desc.EntityDesc; -import org.jiemamy.entity.io.gen.desc.EntitySetDesc; -import org.jiemamy.entity.io.gen.meta.DbForeignKeyMeta; -import org.jiemamy.entity.io.gen.meta.DbTableMeta; -import org.jiemamy.utils.StringUtil; - -/** - * エンティティ記述の関連を解決するクラスです。 - * - * @author j5iko - */ -public class AssociationResolver { - - /** 多側に対する関連名のサフィックス */ - protected static final String TO_MANY_ASSOCIATION_NAME_SUFFIX = "List"; - - /** エンティティ集合記述 */ - protected EntitySetDesc entitySetDesc; - - /** 単語を複数形に変換するための辞書 */ - protected PluralFormDictinary pluralFormDictinary; - - - /** - * インスタンスを構築する。 - * - * @param entitySetDesc エンティティ集合記述 - * @param pluralFormDictinary 単語を複数形に変換するための辞書 - */ - public AssociationResolver(EntitySetDesc entitySetDesc, PluralFormDictinary pluralFormDictinary) { - if (entitySetDesc == null) { - throw new NullPointerException("entitySetDesc"); - } - if (pluralFormDictinary == null) { - throw new NullPointerException("pluralFormDictinary"); - } - this.entitySetDesc = entitySetDesc; - this.pluralFormDictinary = pluralFormDictinary; - } - - /** - * エンティティ記述のすべての属性について必要であれば名前を調整する。 - * - * @param fkMeta 外部キーメタデータ - * @param entityDesc エンティティ記述 - * @param associationName 関連名 - */ - protected void adjustAttributeNames(DbForeignKeyMeta fkMeta, EntityDesc entityDesc, String associationName) { - if (fkMeta.isComposite()) { - return; - } - for (AttributeDesc attributeDesc : entityDesc.getAttributeDescList()) { - if (associationName.equalsIgnoreCase(attributeDesc.getName())) { - String pkColumnName = fkMeta.getPrimaryKeyColumnNameList().get(0); - String pkPropertyName = fromColumnNameToPropertyName(pkColumnName); - String candidateName = attributeDesc.getName() + StringUtil.capitalize(pkPropertyName); - String newName = toUniqueAttributeName(entityDesc, candidateName); - attributeDesc.setName(newName); - } - } - } - - /** - * 被所有側の関連を処理する。 - * - * @param fkMeta 外部キーメタデータ - * @param ownerEntityDesc 関連の所有者側のエンティティ記述 - * @param inverseEntityDesc 関連の被所有者側のエンティティ記述 - * @param mappedBy 関連の所有者側のプロパティ名 - */ - protected void doInverseAssociationDesc(DbForeignKeyMeta fkMeta, EntityDesc ownerEntityDesc, - EntityDesc inverseEntityDesc, String mappedBy) { - AssociationDesc inverseAssociationDesc = new AssociationDesc(); - if (fkMeta.isUnique()) { - String name = getInverseAssociationName(inverseEntityDesc, ownerEntityDesc, false); - inverseAssociationDesc.setName(name); - inverseAssociationDesc.setAssociationType(AssociationType.ONE_TO_ONE); - } else { - String name = getInverseAssociationName(inverseEntityDesc, ownerEntityDesc, true); - inverseAssociationDesc.setName(name); - inverseAssociationDesc.setAssociationType(AssociationType.ONE_TO_MANY); - } - inverseAssociationDesc.setMappedBy(mappedBy); - inverseAssociationDesc.setReferencedEntityDesc(ownerEntityDesc); - inverseEntityDesc.addAssociationDesc(inverseAssociationDesc); - } - - /** - * 所有側の関連を処理する。 - * - * @param fkMeta 外部キーメタデータ - * @param ownerEntityDesc 関連の所有者側のエンティティ記述 - * @param inverseEntityDesc 関連の被所有者側のエンティティ記述 - * @return {@link AssociationDesc} - */ - protected AssociationDesc doOwnerAssociationDesc(DbForeignKeyMeta fkMeta, EntityDesc ownerEntityDesc, - EntityDesc inverseEntityDesc) { - AssociationDesc associationDesc = new AssociationDesc(); - associationDesc.setReferencedCatalogName(fkMeta.getPrimaryKeyCatalogName()); - associationDesc.setReferencedSchemaName(fkMeta.getPrimaryKeySchemaName()); - associationDesc.setReferencedTableName(fkMeta.getPrimaryKeyTableName()); - String name = getOwnerAssociationName(fkMeta, ownerEntityDesc, inverseEntityDesc); - associationDesc.setName(name); - adjustAttributeNames(fkMeta, ownerEntityDesc, name); - if (fkMeta.isUnique()) { - associationDesc.setAssociationType(AssociationType.ONE_TO_ONE); - } else { - associationDesc.setAssociationType(AssociationType.MANY_TO_ONE); - } - for (String referencedColumnName : fkMeta.getPrimaryKeyColumnNameList()) { - associationDesc.addReferencedColumnName(referencedColumnName); - } - for (String columnName : fkMeta.getForeignKeyColumnNameList()) { - associationDesc.addColumnName(columnName); - } - associationDesc.setReferencedEntityDesc(inverseEntityDesc); - ownerEntityDesc.addAssociationDesc(associationDesc); - return associationDesc; - } - - private String fromColumnNameToPropertyName(String pkColumnName) { - // TODO Auto-generated method stub - return null; - } - - /** - * 関連名を取得する。 - * - * @param inverseEntityDesc 参照する側のエンティティ記述 - * @param ownerEntityDesc 参照される側のエンティティ記述 - * @param oneToMany 関連がOneToManyの場合{@code true} - * @return 関連名 - */ - protected String getInverseAssociationName(EntityDesc inverseEntityDesc, EntityDesc ownerEntityDesc, - boolean oneToMany) { - String associationName = StringUtil.decapitalize(ownerEntityDesc.getName()); - if (oneToMany) { - associationName = pluralizeName(associationName); - } - return toUniqueAssociationName(inverseEntityDesc, associationName); - } - - /** - * 関連の所有側の関連名を取得する。 - * - * @param fkMeta 外部キーメタデータ - * @param ownerEntityDesc 関連の所有者側のエンティティ記述 - * @param inverseEntityDesc 関連の被所有者側のエンティティ記述 - * @return 関連の所有側の関連名 - */ - protected String getOwnerAssociationName(DbForeignKeyMeta fkMeta, EntityDesc ownerEntityDesc, - EntityDesc inverseEntityDesc) { - String associationName = StringUtil.decapitalize(inverseEntityDesc.getName()); - if (!fkMeta.isComposite()) { - String fkColumnName = fkMeta.getForeignKeyColumnNameList().get(0); - String pkColumnName = fkMeta.getPrimaryKeyColumnNameList().get(0); - if (StringUtil.endsWithIgnoreCase(fkColumnName, pkColumnName)) { - if (fkColumnName.length() > pkColumnName.length()) { - String name = fkColumnName.substring(0, fkColumnName.length() - pkColumnName.length()); - name = StringUtil.trimSuffix(name, "_"); - name = StringUtil.camelize(name); - if (StringUtil.startsWithIgnoreCase(pkColumnName, inverseEntityDesc.getTableName())) { - associationName = StringUtil.decapitalize(name) + inverseEntityDesc.getName(); - } else { - associationName = StringUtil.decapitalize(name); - } - } - } - } - return toUniqueAssociationName(ownerEntityDesc, associationName); - } - - /** - * 名前を複数形に変換する。 - * - * @param name 名前 - * @return 複数形に変換された名前 - */ - protected String pluralizeName(String name) { - String pluralizedName = pluralFormDictinary.lookup(name); - if (pluralizedName != null) { - return pluralizedName; - } - return name + TO_MANY_ASSOCIATION_NAME_SUFFIX; - } - - /** - * 関連を解決する。 - * - * @param tableMeta テーブルメタデータ - * @param fkMeta 外部キーメタデータ - */ - public void resolve(DbTableMeta tableMeta, DbForeignKeyMeta fkMeta) { - EntityDesc ownerEntityDesc = entitySetDesc.getEntityDesc(tableMeta.getFullName()); - if (ownerEntityDesc == null) { - return; - } - EntityDesc inverseEntityDesc = entitySetDesc.getEntityDesc(fkMeta.getPrimaryKeyFullTableName()); - if (inverseEntityDesc == null) { - return; - } - AssociationDesc ownerAssociationDesc = doOwnerAssociationDesc(fkMeta, ownerEntityDesc, inverseEntityDesc); - doInverseAssociationDesc(fkMeta, ownerEntityDesc, inverseEntityDesc, ownerAssociationDesc.getName()); - } - - /** - * 一意の関連名に変換する。 - * - * @param entityDesc エンティティ記述 - * @param candidateName 候補の関連名 - * @return 一意の関連名 - */ - protected String toUniqueAssociationName(EntityDesc entityDesc, String candidateName) { - if (entityDesc.hasAssociationDesc(candidateName)) { - for (int i = 2;; i++) { - if (!entityDesc.hasAssociationDesc(candidateName + i)) { - return candidateName + i; - } - } - } - return candidateName; - } - - /** - * 一意な属性名に変換する。 - * - * @param entityDesc エンティティ記述 - * @param candidateName 候補の属性名 - * @return 一意な属性名 - */ - protected String toUniqueAttributeName(EntityDesc entityDesc, String candidateName) { - if (entityDesc.hasAttributeDesc(candidateName)) { - for (int i = 2;; i++) { - if (!entityDesc.hasAttributeDesc(candidateName + i)) { - return candidateName + i; - } - } - } - return candidateName; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc.impl; + +import org.jiemamy.entity.io.gen.desc.AssociationDesc; +import org.jiemamy.entity.io.gen.desc.AssociationType; +import org.jiemamy.entity.io.gen.desc.AttributeDesc; +import org.jiemamy.entity.io.gen.desc.EntityDesc; +import org.jiemamy.entity.io.gen.desc.EntitySetDesc; +import org.jiemamy.entity.io.gen.meta.DbForeignKeyMeta; +import org.jiemamy.entity.io.gen.meta.DbTableMeta; +import org.jiemamy.utils.StringUtil; + +/** + * エンティティ記述の関連を解決するクラスです。 + * + * @author j5iko + */ +public class AssociationResolver { + + /** 多側に対する関連名のサフィックス */ + protected static final String TO_MANY_ASSOCIATION_NAME_SUFFIX = "List"; + + /** エンティティ集合記述 */ + protected EntitySetDesc entitySetDesc; + + /** 単語を複数形に変換するための辞書 */ + protected PluralFormDictinary pluralFormDictinary; + + + /** + * インスタンスを構築する。 + * + * @param entitySetDesc エンティティ集合記述 + * @param pluralFormDictinary 単語を複数形に変換するための辞書 + */ + public AssociationResolver(EntitySetDesc entitySetDesc, PluralFormDictinary pluralFormDictinary) { + if (entitySetDesc == null) { + throw new NullPointerException("entitySetDesc"); + } + if (pluralFormDictinary == null) { + throw new NullPointerException("pluralFormDictinary"); + } + this.entitySetDesc = entitySetDesc; + this.pluralFormDictinary = pluralFormDictinary; + } + + /** + * エンティティ記述のすべての属性について必要であれば名前を調整する。 + * + * @param fkMeta 外部キーメタデータ + * @param entityDesc エンティティ記述 + * @param associationName 関連名 + */ + protected void adjustAttributeNames(DbForeignKeyMeta fkMeta, EntityDesc entityDesc, String associationName) { + if (fkMeta.isComposite()) { + return; + } + for (AttributeDesc attributeDesc : entityDesc.getAttributeDescList()) { + if (associationName.equalsIgnoreCase(attributeDesc.getName())) { + String pkColumnName = fkMeta.getPrimaryKeyColumnNameList().get(0); + String pkPropertyName = fromColumnNameToPropertyName(pkColumnName); + String candidateName = attributeDesc.getName() + StringUtil.capitalize(pkPropertyName); + String newName = toUniqueAttributeName(entityDesc, candidateName); + attributeDesc.setName(newName); + } + } + } + + /** + * 被所有側の関連を処理する。 + * + * @param fkMeta 外部キーメタデータ + * @param ownerEntityDesc 関連の所有者側のエンティティ記述 + * @param inverseEntityDesc 関連の被所有者側のエンティティ記述 + * @param mappedBy 関連の所有者側のプロパティ名 + */ + protected void doInverseAssociationDesc(DbForeignKeyMeta fkMeta, EntityDesc ownerEntityDesc, + EntityDesc inverseEntityDesc, String mappedBy) { + AssociationDesc inverseAssociationDesc = new AssociationDesc(); + if (fkMeta.isUnique()) { + String name = getInverseAssociationName(inverseEntityDesc, ownerEntityDesc, false); + inverseAssociationDesc.setName(name); + inverseAssociationDesc.setAssociationType(AssociationType.ONE_TO_ONE); + } else { + String name = getInverseAssociationName(inverseEntityDesc, ownerEntityDesc, true); + inverseAssociationDesc.setName(name); + inverseAssociationDesc.setAssociationType(AssociationType.ONE_TO_MANY); + } + inverseAssociationDesc.setMappedBy(mappedBy); + inverseAssociationDesc.setReferencedEntityDesc(ownerEntityDesc); + inverseEntityDesc.addAssociationDesc(inverseAssociationDesc); + } + + /** + * 所有側の関連を処理する。 + * + * @param fkMeta 外部キーメタデータ + * @param ownerEntityDesc 関連の所有者側のエンティティ記述 + * @param inverseEntityDesc 関連の被所有者側のエンティティ記述 + * @return {@link AssociationDesc} + */ + protected AssociationDesc doOwnerAssociationDesc(DbForeignKeyMeta fkMeta, EntityDesc ownerEntityDesc, + EntityDesc inverseEntityDesc) { + AssociationDesc associationDesc = new AssociationDesc(); + associationDesc.setReferencedCatalogName(fkMeta.getPrimaryKeyCatalogName()); + associationDesc.setReferencedSchemaName(fkMeta.getPrimaryKeySchemaName()); + associationDesc.setReferencedTableName(fkMeta.getPrimaryKeyTableName()); + String name = getOwnerAssociationName(fkMeta, ownerEntityDesc, inverseEntityDesc); + associationDesc.setName(name); + adjustAttributeNames(fkMeta, ownerEntityDesc, name); + if (fkMeta.isUnique()) { + associationDesc.setAssociationType(AssociationType.ONE_TO_ONE); + } else { + associationDesc.setAssociationType(AssociationType.MANY_TO_ONE); + } + for (String referencedColumnName : fkMeta.getPrimaryKeyColumnNameList()) { + associationDesc.addReferencedColumnName(referencedColumnName); + } + for (String columnName : fkMeta.getForeignKeyColumnNameList()) { + associationDesc.addColumnName(columnName); + } + associationDesc.setReferencedEntityDesc(inverseEntityDesc); + ownerEntityDesc.addAssociationDesc(associationDesc); + return associationDesc; + } + + private String fromColumnNameToPropertyName(String pkColumnName) { + // TODO Auto-generated method stub + return null; + } + + /** + * 関連名を取得する。 + * + * @param inverseEntityDesc 参照する側のエンティティ記述 + * @param ownerEntityDesc 参照される側のエンティティ記述 + * @param oneToMany 関連がOneToManyの場合{@code true} + * @return 関連名 + */ + protected String getInverseAssociationName(EntityDesc inverseEntityDesc, EntityDesc ownerEntityDesc, + boolean oneToMany) { + String associationName = StringUtil.decapitalize(ownerEntityDesc.getName()); + if (oneToMany) { + associationName = pluralizeName(associationName); + } + return toUniqueAssociationName(inverseEntityDesc, associationName); + } + + /** + * 関連の所有側の関連名を取得する。 + * + * @param fkMeta 外部キーメタデータ + * @param ownerEntityDesc 関連の所有者側のエンティティ記述 + * @param inverseEntityDesc 関連の被所有者側のエンティティ記述 + * @return 関連の所有側の関連名 + */ + protected String getOwnerAssociationName(DbForeignKeyMeta fkMeta, EntityDesc ownerEntityDesc, + EntityDesc inverseEntityDesc) { + String associationName = StringUtil.decapitalize(inverseEntityDesc.getName()); + if (!fkMeta.isComposite()) { + String fkColumnName = fkMeta.getForeignKeyColumnNameList().get(0); + String pkColumnName = fkMeta.getPrimaryKeyColumnNameList().get(0); + if (StringUtil.endsWithIgnoreCase(fkColumnName, pkColumnName)) { + if (fkColumnName.length() > pkColumnName.length()) { + String name = fkColumnName.substring(0, fkColumnName.length() - pkColumnName.length()); + name = StringUtil.trimSuffix(name, "_"); + name = StringUtil.camelize(name); + if (StringUtil.startsWithIgnoreCase(pkColumnName, inverseEntityDesc.getTableName())) { + associationName = StringUtil.decapitalize(name) + inverseEntityDesc.getName(); + } else { + associationName = StringUtil.decapitalize(name); + } + } + } + } + return toUniqueAssociationName(ownerEntityDesc, associationName); + } + + /** + * 名前を複数形に変換する。 + * + * @param name 名前 + * @return 複数形に変換された名前 + */ + protected String pluralizeName(String name) { + String pluralizedName = pluralFormDictinary.lookup(name); + if (pluralizedName != null) { + return pluralizedName; + } + return name + TO_MANY_ASSOCIATION_NAME_SUFFIX; + } + + /** + * 関連を解決する。 + * + * @param tableMeta テーブルメタデータ + * @param fkMeta 外部キーメタデータ + */ + public void resolve(DbTableMeta tableMeta, DbForeignKeyMeta fkMeta) { + EntityDesc ownerEntityDesc = entitySetDesc.getEntityDesc(tableMeta.getFullName()); + if (ownerEntityDesc == null) { + return; + } + EntityDesc inverseEntityDesc = entitySetDesc.getEntityDesc(fkMeta.getPrimaryKeyFullTableName()); + if (inverseEntityDesc == null) { + return; + } + AssociationDesc ownerAssociationDesc = doOwnerAssociationDesc(fkMeta, ownerEntityDesc, inverseEntityDesc); + doInverseAssociationDesc(fkMeta, ownerEntityDesc, inverseEntityDesc, ownerAssociationDesc.getName()); + } + + /** + * 一意の関連名に変換する。 + * + * @param entityDesc エンティティ記述 + * @param candidateName 候補の関連名 + * @return 一意の関連名 + */ + protected String toUniqueAssociationName(EntityDesc entityDesc, String candidateName) { + if (entityDesc.hasAssociationDesc(candidateName)) { + for (int i = 2;; i++) { + if (!entityDesc.hasAssociationDesc(candidateName + i)) { + return candidateName + i; + } + } + } + return candidateName; + } + + /** + * 一意な属性名に変換する。 + * + * @param entityDesc エンティティ記述 + * @param candidateName 候補の属性名 + * @return 一意な属性名 + */ + protected String toUniqueAttributeName(EntityDesc entityDesc, String candidateName) { + if (entityDesc.hasAttributeDesc(candidateName)) { + for (int i = 2;; i++) { + if (!entityDesc.hasAttributeDesc(candidateName + i)) { + return candidateName + i; + } + } + } + return candidateName; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/AssociationResolver.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/AttributeDescFactoryImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/AttributeDescFactoryImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/AttributeDescFactoryImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,213 +1,213 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc.impl; - -import java.util.regex.Pattern; - -import javax.persistence.GenerationType; -import javax.persistence.SequenceGenerator; -import javax.persistence.TableGenerator; -import javax.persistence.Version; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.entity.io.convensition.PersistenceConvention; -import org.jiemamy.entity.io.gen.desc.AttributeDesc; -import org.jiemamy.entity.io.gen.desc.AttributeDescFactory; -import org.jiemamy.entity.io.gen.dialect.GenDialect; -import org.jiemamy.entity.io.gen.meta.DbColumnMeta; -import org.jiemamy.entity.io.gen.meta.DbTableMeta; -import org.jiemamy.entity.io.utils.AnnotationUtil; -import org.jiemamy.utils.ClassUtil; - -/** - * {@link AttributeDescFactory}の実装クラスです。 - * - * @author j5ik2o - */ -public class AttributeDescFactoryImpl implements AttributeDescFactory { - - /** バージョンカラム名のパターン */ - protected Pattern versionColumnNamePattern; - - /** エンティティの識別子の生成方法を示す列挙型 、生成しない場合は{@code null} */ - protected GenerationType generationType; - - /** エンティティの識別子の初期値 */ - protected int initialValue; - - /** エンティティの識別子の割り当てサイズ */ - protected int allocationSize; - - /** SQL方言 */ - protected GenDialect dialect; - - private PersistenceConvention persistenceConvention; - - - /** - * インスタンスを構築する。 - * - * @param persistenceConvention 永続化層の命名規約 - * @param dialect SQL方言 - * @param versionColumnNamePattern バージョンカラム名のパターン - * @param generationType エンティティの識別子の生成方法を示す列挙型 、生成しない場合は{@code null} - * @param initialValue エンティティの識別子の初期値、指定しない場合は{@code null} - * @param allocationSize エンティティの識別子の割り当てサイズ、指定しない場合は{@code null} - * @throws IdentityNotSupportedException IDENTITYがサポートされていない場合 - */ - public AttributeDescFactoryImpl(PersistenceConvention persistenceConvention, GenDialect dialect, - Pattern versionColumnNamePattern, GenerationType generationType, Integer initialValue, - Integer allocationSize) throws IdentityNotSupportedException { - Validate.notNull(dialect); - Validate.notNull(versionColumnNamePattern); - this.persistenceConvention = persistenceConvention; - this.dialect = dialect; - this.versionColumnNamePattern = versionColumnNamePattern; - this.generationType = - generationType == GenerationType.AUTO ? dialect.getDefaultGenerationType() : generationType; - if (this.generationType == GenerationType.IDENTITY) { - if (dialect.supportsIdentity() == false) { - throw new IdentityNotSupportedException(); - } - } else if (this.generationType == GenerationType.SEQUENCE) { - SequenceGenerator generator = AnnotationUtil.getDefaultSequenceGenerator(); - this.initialValue = initialValue != null ? initialValue : generator.initialValue(); - this.allocationSize = allocationSize != null ? allocationSize : generator.allocationSize(); - } else if (this.generationType == GenerationType.TABLE) { - TableGenerator generator = AnnotationUtil.getDefaultTableGenerator(); - this.initialValue = initialValue != null ? initialValue : generator.initialValue(); - this.allocationSize = allocationSize != null ? allocationSize : generator.allocationSize(); - } - } - - /** - * カラムを処理する。 - * - * @param tableMeta テーブルメタデータ - * @param columnMeta カラムメタデータ - * @param attributeDesc 属性記述 - */ - protected void doColumn(DbTableMeta tableMeta, DbColumnMeta columnMeta, AttributeDesc attributeDesc) { - attributeDesc.setColumnName(columnMeta.getName()); - attributeDesc.setColumnTypeName(columnMeta.getTypeName()); - attributeDesc.setLength(columnMeta.getLength()); - attributeDesc.setPrecision(columnMeta.getLength()); - attributeDesc.setScale(columnMeta.getScale()); - attributeDesc.setNullable(columnMeta.isNullable()); - attributeDesc.setUnique(columnMeta.isUnique()); - attributeDesc.setComment(columnMeta.getComment()); - GenDialect.ColumnType columnType = dialect.getColumnType(columnMeta.getTypeName(), columnMeta.getSqlType()); - if (columnType != null) { - Class<?> clazz = - columnType.getAttributeClass(columnMeta.getLength(), columnMeta.getLength(), columnMeta.getScale()); - attributeDesc.setAttributeClass(clazz); - String defaultValue = attributeDesc.getGenerationType() != null ? null : columnMeta.getDefaultValue(); - String definition = - columnType.getColumnDefinition(columnMeta.getLength(), columnMeta.getLength(), columnMeta - .getScale(), defaultValue); - attributeDesc.setColumnDefinition(definition); - attributeDesc.setLob(columnType.isLob()); - } else { - attributeDesc.setUnsupportedColumnType(true); - attributeDesc.setAttributeClass(String.class); - attributeDesc.setLob(false); - } - } - - /** - * 識別子を処理する。 - * - * @param tableMeta テーブルメタデータ - * @param columnMeta カラムメタデータ - * @param attributeDesc 属性記述 - */ - protected void doId(DbTableMeta tableMeta, DbColumnMeta columnMeta, AttributeDesc attributeDesc) { - if (columnMeta.isPrimaryKey()) { - attributeDesc.setId(true); - if (!tableMeta.hasCompositePrimaryKey()) { - if (columnMeta.isAutoIncrement()) { - attributeDesc.setGenerationType(GenerationType.IDENTITY); - } else { - attributeDesc.setGenerationType(generationType); - attributeDesc.setInitialValue(initialValue); - attributeDesc.setAllocationSize(allocationSize); - } - } - } - } - - /** - * 名前を処理する。 - * - * @param tableMeta テーブルメタデータ - * @param columnMeta カラムメタデータ - * @param attributeDesc 属性記述 - */ - protected void doName(DbTableMeta tableMeta, DbColumnMeta columnMeta, AttributeDesc attributeDesc) { - attributeDesc.setName(persistenceConvention.fromColumnNameToPropertyName(columnMeta.getName())); - } - - /** - * 一時的なプロパティを処理する。 - * - * @param tableMeta テーブルメタデータ - * @param columnMeta カラムメタデータ - * @param attributeDesc 属性記述 - */ - protected void doTransient(DbTableMeta tableMeta, DbColumnMeta columnMeta, AttributeDesc attributeDesc) { - } - - /** - * バージョンを処理する。 - * - * @param tableMeta テーブルメタデータ - * @param columnMeta カラムメタデータ - * @param attributeDesc 属性記述 - */ - protected void doVersion(DbTableMeta tableMeta, DbColumnMeta columnMeta, AttributeDesc attributeDesc) { - if (isVersionAnnotatable(attributeDesc.getAttributeClass())) { - if (versionColumnNamePattern.matcher(columnMeta.getName()).matches()) { - attributeDesc.setVersion(true); - } - } - } - - public AttributeDesc getAttributeDesc(DbTableMeta tableMeta, DbColumnMeta columnMeta) { - AttributeDesc attributeDesc = new AttributeDesc(); - doName(tableMeta, columnMeta, attributeDesc); - doId(tableMeta, columnMeta, attributeDesc); - doTransient(tableMeta, columnMeta, attributeDesc); - doColumn(tableMeta, columnMeta, attributeDesc); - doVersion(tableMeta, columnMeta, attributeDesc); - return attributeDesc; - } - - /** - * {@link Version}を注釈できるクラスの場合{@code true} - * - * @param clazz クラス - * @return {@link Version}を注釈できるクラスの場合{@code true} - */ - protected boolean isVersionAnnotatable(Class<?> clazz) { - Class<?> wrapperClass = ClassUtil.getWrapperClassIfPrimitive(clazz); - return wrapperClass == Integer.class || wrapperClass == Long.class; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc.impl; + +import java.util.regex.Pattern; + +import javax.persistence.GenerationType; +import javax.persistence.SequenceGenerator; +import javax.persistence.TableGenerator; +import javax.persistence.Version; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.entity.io.convensition.PersistenceConvention; +import org.jiemamy.entity.io.gen.desc.AttributeDesc; +import org.jiemamy.entity.io.gen.desc.AttributeDescFactory; +import org.jiemamy.entity.io.gen.dialect.GenDialect; +import org.jiemamy.entity.io.gen.meta.DbColumnMeta; +import org.jiemamy.entity.io.gen.meta.DbTableMeta; +import org.jiemamy.entity.io.utils.AnnotationUtil; +import org.jiemamy.utils.ClassUtil; + +/** + * {@link AttributeDescFactory}の実装クラスです。 + * + * @author j5ik2o + */ +public class AttributeDescFactoryImpl implements AttributeDescFactory { + + /** バージョンカラム名のパターン */ + protected Pattern versionColumnNamePattern; + + /** エンティティの識別子の生成方法を示す列挙型 、生成しない場合は{@code null} */ + protected GenerationType generationType; + + /** エンティティの識別子の初期値 */ + protected int initialValue; + + /** エンティティの識別子の割り当てサイズ */ + protected int allocationSize; + + /** SQL方言 */ + protected GenDialect dialect; + + private PersistenceConvention persistenceConvention; + + + /** + * インスタンスを構築する。 + * + * @param persistenceConvention 永続化層の命名規約 + * @param dialect SQL方言 + * @param versionColumnNamePattern バージョンカラム名のパターン + * @param generationType エンティティの識別子の生成方法を示す列挙型 、生成しない場合は{@code null} + * @param initialValue エンティティの識別子の初期値、指定しない場合は{@code null} + * @param allocationSize エンティティの識別子の割り当てサイズ、指定しない場合は{@code null} + * @throws IdentityNotSupportedException IDENTITYがサポートされていない場合 + */ + public AttributeDescFactoryImpl(PersistenceConvention persistenceConvention, GenDialect dialect, + Pattern versionColumnNamePattern, GenerationType generationType, Integer initialValue, + Integer allocationSize) throws IdentityNotSupportedException { + Validate.notNull(dialect); + Validate.notNull(versionColumnNamePattern); + this.persistenceConvention = persistenceConvention; + this.dialect = dialect; + this.versionColumnNamePattern = versionColumnNamePattern; + this.generationType = + generationType == GenerationType.AUTO ? dialect.getDefaultGenerationType() : generationType; + if (this.generationType == GenerationType.IDENTITY) { + if (dialect.supportsIdentity() == false) { + throw new IdentityNotSupportedException(); + } + } else if (this.generationType == GenerationType.SEQUENCE) { + SequenceGenerator generator = AnnotationUtil.getDefaultSequenceGenerator(); + this.initialValue = initialValue != null ? initialValue : generator.initialValue(); + this.allocationSize = allocationSize != null ? allocationSize : generator.allocationSize(); + } else if (this.generationType == GenerationType.TABLE) { + TableGenerator generator = AnnotationUtil.getDefaultTableGenerator(); + this.initialValue = initialValue != null ? initialValue : generator.initialValue(); + this.allocationSize = allocationSize != null ? allocationSize : generator.allocationSize(); + } + } + + /** + * カラムを処理する。 + * + * @param tableMeta テーブルメタデータ + * @param columnMeta カラムメタデータ + * @param attributeDesc 属性記述 + */ + protected void doColumn(DbTableMeta tableMeta, DbColumnMeta columnMeta, AttributeDesc attributeDesc) { + attributeDesc.setColumnName(columnMeta.getName()); + attributeDesc.setColumnTypeName(columnMeta.getTypeName()); + attributeDesc.setLength(columnMeta.getLength()); + attributeDesc.setPrecision(columnMeta.getLength()); + attributeDesc.setScale(columnMeta.getScale()); + attributeDesc.setNullable(columnMeta.isNullable()); + attributeDesc.setUnique(columnMeta.isUnique()); + attributeDesc.setComment(columnMeta.getComment()); + GenDialect.ColumnType columnType = dialect.getColumnType(columnMeta.getTypeName(), columnMeta.getSqlType()); + if (columnType != null) { + Class<?> clazz = + columnType.getAttributeClass(columnMeta.getLength(), columnMeta.getLength(), columnMeta.getScale()); + attributeDesc.setAttributeClass(clazz); + String defaultValue = attributeDesc.getGenerationType() != null ? null : columnMeta.getDefaultValue(); + String definition = + columnType.getColumnDefinition(columnMeta.getLength(), columnMeta.getLength(), columnMeta + .getScale(), defaultValue); + attributeDesc.setColumnDefinition(definition); + attributeDesc.setLob(columnType.isLob()); + } else { + attributeDesc.setUnsupportedColumnType(true); + attributeDesc.setAttributeClass(String.class); + attributeDesc.setLob(false); + } + } + + /** + * 識別子を処理する。 + * + * @param tableMeta テーブルメタデータ + * @param columnMeta カラムメタデータ + * @param attributeDesc 属性記述 + */ + protected void doId(DbTableMeta tableMeta, DbColumnMeta columnMeta, AttributeDesc attributeDesc) { + if (columnMeta.isPrimaryKey()) { + attributeDesc.setId(true); + if (!tableMeta.hasCompositePrimaryKey()) { + if (columnMeta.isAutoIncrement()) { + attributeDesc.setGenerationType(GenerationType.IDENTITY); + } else { + attributeDesc.setGenerationType(generationType); + attributeDesc.setInitialValue(initialValue); + attributeDesc.setAllocationSize(allocationSize); + } + } + } + } + + /** + * 名前を処理する。 + * + * @param tableMeta テーブルメタデータ + * @param columnMeta カラムメタデータ + * @param attributeDesc 属性記述 + */ + protected void doName(DbTableMeta tableMeta, DbColumnMeta columnMeta, AttributeDesc attributeDesc) { + attributeDesc.setName(persistenceConvention.fromColumnNameToPropertyName(columnMeta.getName())); + } + + /** + * 一時的なプロパティを処理する。 + * + * @param tableMeta テーブルメタデータ + * @param columnMeta カラムメタデータ + * @param attributeDesc 属性記述 + */ + protected void doTransient(DbTableMeta tableMeta, DbColumnMeta columnMeta, AttributeDesc attributeDesc) { + } + + /** + * バージョンを処理する。 + * + * @param tableMeta テーブルメタデータ + * @param columnMeta カラムメタデータ + * @param attributeDesc 属性記述 + */ + protected void doVersion(DbTableMeta tableMeta, DbColumnMeta columnMeta, AttributeDesc attributeDesc) { + if (isVersionAnnotatable(attributeDesc.getAttributeClass())) { + if (versionColumnNamePattern.matcher(columnMeta.getName()).matches()) { + attributeDesc.setVersion(true); + } + } + } + + public AttributeDesc getAttributeDesc(DbTableMeta tableMeta, DbColumnMeta columnMeta) { + AttributeDesc attributeDesc = new AttributeDesc(); + doName(tableMeta, columnMeta, attributeDesc); + doId(tableMeta, columnMeta, attributeDesc); + doTransient(tableMeta, columnMeta, attributeDesc); + doColumn(tableMeta, columnMeta, attributeDesc); + doVersion(tableMeta, columnMeta, attributeDesc); + return attributeDesc; + } + + /** + * {@link Version}を注釈できるクラスの場合{@code true} + * + * @param clazz クラス + * @return {@link Version}を注釈できるクラスの場合{@code true} + */ + protected boolean isVersionAnnotatable(Class<?> clazz) { + Class<?> wrapperClass = ClassUtil.getWrapperClassIfPrimitive(clazz); + return wrapperClass == Integer.class || wrapperClass == Long.class; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/AttributeDescFactoryImpl.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/CompositeUniqueConstraintDescFactoryImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/CompositeUniqueConstraintDescFactoryImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/CompositeUniqueConstraintDescFactoryImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,42 +1,42 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc.impl; - -import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDesc; -import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDescFactory; -import org.jiemamy.entity.io.gen.meta.DbUniqueKeyMeta; - -/** - * {@link CompositeUniqueConstraintDescFactory}の実装クラス。 - * - * @author j5ik2o - */ -public class CompositeUniqueConstraintDescFactoryImpl implements CompositeUniqueConstraintDescFactory { - - public CompositeUniqueConstraintDesc getCompositeUniqueConstraintDesc(DbUniqueKeyMeta uniqueKeyMeta) { - if (uniqueKeyMeta.isPrimaryKey() || !uniqueKeyMeta.isComposite()) { - return null; - } - CompositeUniqueConstraintDesc compositeUniqueConstraintDesc = new CompositeUniqueConstraintDesc(); - for (String columnName : uniqueKeyMeta.getColumnNameList()) { - compositeUniqueConstraintDesc.addColumnName(columnName); - } - return compositeUniqueConstraintDesc; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc.impl; + +import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDesc; +import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDescFactory; +import org.jiemamy.entity.io.gen.meta.DbUniqueKeyMeta; + +/** + * {@link CompositeUniqueConstraintDescFactory}の実装クラス。 + * + * @author j5ik2o + */ +public class CompositeUniqueConstraintDescFactoryImpl implements CompositeUniqueConstraintDescFactory { + + public CompositeUniqueConstraintDesc getCompositeUniqueConstraintDesc(DbUniqueKeyMeta uniqueKeyMeta) { + if (uniqueKeyMeta.isPrimaryKey() || !uniqueKeyMeta.isComposite()) { + return null; + } + CompositeUniqueConstraintDesc compositeUniqueConstraintDesc = new CompositeUniqueConstraintDesc(); + for (String columnName : uniqueKeyMeta.getColumnNameList()) { + compositeUniqueConstraintDesc.addColumnName(columnName); + } + return compositeUniqueConstraintDesc; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/CompositeUniqueConstraintDescFactoryImpl.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescFactoryImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescFactoryImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescFactoryImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,133 +1,133 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc.impl; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.entity.io.convensition.PersistenceConvention; -import org.jiemamy.entity.io.gen.desc.AttributeDesc; -import org.jiemamy.entity.io.gen.desc.AttributeDescFactory; -import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDesc; -import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDescFactory; -import org.jiemamy.entity.io.gen.desc.EntityDesc; -import org.jiemamy.entity.io.gen.desc.EntityDescFactory; -import org.jiemamy.entity.io.gen.meta.DbColumnMeta; -import org.jiemamy.entity.io.gen.meta.DbTableMeta; -import org.jiemamy.entity.io.gen.meta.DbUniqueKeyMeta; - -/** - * {@link EntityDescFactory}の実装クラスです。 - * - * @author j5ik2o - */ -public class EntityDescFactoryImpl implements EntityDescFactory { - - /** 属性記述のファクトリ */ - protected AttributeDescFactory attributeDescFactory; - - /** 複合一意制約記述のファクトリ */ - protected CompositeUniqueConstraintDescFactory compositeUniqueConstraintDescFactory; - - /** スキーマが指定されている場合{@code true} */ - protected boolean schemaSpecified; - - /** 永続化層の命名規約 */ - protected PersistenceConvention persistenceConvention; - - - /** - * インスタンスを生成する。 - * - * @param persistenceConvention 永続化層の命名規約 - * @param compositeUniqueConstraintDescFactory 複合一意制約記述のファクトリ - * @param attributeDescFactory 属性記述のファクトリ - */ - public EntityDescFactoryImpl(PersistenceConvention persistenceConvention, - AttributeDescFactory attributeDescFactory, - CompositeUniqueConstraintDescFactory compositeUniqueConstraintDescFactory) { - Validate.notNull(persistenceConvention); - Validate.notNull(attributeDescFactory); - Validate.notNull(compositeUniqueConstraintDescFactory); - this.persistenceConvention = persistenceConvention; - this.attributeDescFactory = attributeDescFactory; - this.compositeUniqueConstraintDescFactory = compositeUniqueConstraintDescFactory; - } - - /** - * 属性記述を処理する。 - * - * @param tableMeta テーブルメタデータ - * @param entityDesc エンティティ記述 - */ - protected void doAttributeDesc(DbTableMeta tableMeta, EntityDesc entityDesc) { - for (DbColumnMeta columnMeta : tableMeta.getColumnMetaList()) { - AttributeDesc attributeDesc = attributeDescFactory.getAttributeDesc(tableMeta, columnMeta); - entityDesc.addAttributeDesc(attributeDesc); - } - } - - /** - * 複合一意制約記述を処理する。 - * - * @param tableMeta テーブルメタデータ - * @param entityDesc エンティティ記述 - */ - protected void doCompositeUniqueConstraintDesc(DbTableMeta tableMeta, EntityDesc entityDesc) { - for (DbUniqueKeyMeta uniqueKeyMeta : tableMeta.getUniqueKeyMetaList()) { - CompositeUniqueConstraintDesc compositeUniqueConstraintDesc = - compositeUniqueConstraintDescFactory.getCompositeUniqueConstraintDesc(uniqueKeyMeta); - if (compositeUniqueConstraintDesc != null) { - entityDesc.addCompositeUniqueConstraintDesc(compositeUniqueConstraintDesc); - } - } - } - - /** - * 名前を処理する。 - * - * @param tableMeta テーブルメタ情報 - * @param entityDesc エンティティ記述 - */ - protected void doName(DbTableMeta tableMeta, EntityDesc entityDesc) { - entityDesc.setName(persistenceConvention.fromTableNameToEntityName(tableMeta.getName())); - } - - /** - * テーブルを処理する。 - * - * @param tableMeta テーブルメタ情報 - * @param entityDesc エンティティ記述 - */ - protected void doTable(DbTableMeta tableMeta, EntityDesc entityDesc) { - entityDesc.setCatalogName(tableMeta.getCatalogName()); - entityDesc.setSchemaName(tableMeta.getSchemaName()); - entityDesc.setTableName(tableMeta.getName()); - entityDesc.setComment(tableMeta.getComment()); - } - - public EntityDesc getEntityDesc(DbTableMeta tableMeta) { - EntityDesc entityDesc = new EntityDesc(); - doName(tableMeta, entityDesc); - doTable(tableMeta, entityDesc); - doAttributeDesc(tableMeta, entityDesc); - doCompositeUniqueConstraintDesc(tableMeta, entityDesc); - return entityDesc; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc.impl; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.entity.io.convensition.PersistenceConvention; +import org.jiemamy.entity.io.gen.desc.AttributeDesc; +import org.jiemamy.entity.io.gen.desc.AttributeDescFactory; +import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDesc; +import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDescFactory; +import org.jiemamy.entity.io.gen.desc.EntityDesc; +import org.jiemamy.entity.io.gen.desc.EntityDescFactory; +import org.jiemamy.entity.io.gen.meta.DbColumnMeta; +import org.jiemamy.entity.io.gen.meta.DbTableMeta; +import org.jiemamy.entity.io.gen.meta.DbUniqueKeyMeta; + +/** + * {@link EntityDescFactory}の実装クラスです。 + * + * @author j5ik2o + */ +public class EntityDescFactoryImpl implements EntityDescFactory { + + /** 属性記述のファクトリ */ + protected AttributeDescFactory attributeDescFactory; + + /** 複合一意制約記述のファクトリ */ + protected CompositeUniqueConstraintDescFactory compositeUniqueConstraintDescFactory; + + /** スキーマが指定されている場合{@code true} */ + protected boolean schemaSpecified; + + /** 永続化層の命名規約 */ + protected PersistenceConvention persistenceConvention; + + + /** + * インスタンスを生成する。 + * + * @param persistenceConvention 永続化層の命名規約 + * @param compositeUniqueConstraintDescFactory 複合一意制約記述のファクトリ + * @param attributeDescFactory 属性記述のファクトリ + */ + public EntityDescFactoryImpl(PersistenceConvention persistenceConvention, + AttributeDescFactory attributeDescFactory, + CompositeUniqueConstraintDescFactory compositeUniqueConstraintDescFactory) { + Validate.notNull(persistenceConvention); + Validate.notNull(attributeDescFactory); + Validate.notNull(compositeUniqueConstraintDescFactory); + this.persistenceConvention = persistenceConvention; + this.attributeDescFactory = attributeDescFactory; + this.compositeUniqueConstraintDescFactory = compositeUniqueConstraintDescFactory; + } + + /** + * 属性記述を処理する。 + * + * @param tableMeta テーブルメタデータ + * @param entityDesc エンティティ記述 + */ + protected void doAttributeDesc(DbTableMeta tableMeta, EntityDesc entityDesc) { + for (DbColumnMeta columnMeta : tableMeta.getColumnMetaList()) { + AttributeDesc attributeDesc = attributeDescFactory.getAttributeDesc(tableMeta, columnMeta); + entityDesc.addAttributeDesc(attributeDesc); + } + } + + /** + * 複合一意制約記述を処理する。 + * + * @param tableMeta テーブルメタデータ + * @param entityDesc エンティティ記述 + */ + protected void doCompositeUniqueConstraintDesc(DbTableMeta tableMeta, EntityDesc entityDesc) { + for (DbUniqueKeyMeta uniqueKeyMeta : tableMeta.getUniqueKeyMetaList()) { + CompositeUniqueConstraintDesc compositeUniqueConstraintDesc = + compositeUniqueConstraintDescFactory.getCompositeUniqueConstraintDesc(uniqueKeyMeta); + if (compositeUniqueConstraintDesc != null) { + entityDesc.addCompositeUniqueConstraintDesc(compositeUniqueConstraintDesc); + } + } + } + + /** + * 名前を処理する。 + * + * @param tableMeta テーブルメタ情報 + * @param entityDesc エンティティ記述 + */ + protected void doName(DbTableMeta tableMeta, EntityDesc entityDesc) { + entityDesc.setName(persistenceConvention.fromTableNameToEntityName(tableMeta.getName())); + } + + /** + * テーブルを処理する。 + * + * @param tableMeta テーブルメタ情報 + * @param entityDesc エンティティ記述 + */ + protected void doTable(DbTableMeta tableMeta, EntityDesc entityDesc) { + entityDesc.setCatalogName(tableMeta.getCatalogName()); + entityDesc.setSchemaName(tableMeta.getSchemaName()); + entityDesc.setTableName(tableMeta.getName()); + entityDesc.setComment(tableMeta.getComment()); + } + + public EntityDesc getEntityDesc(DbTableMeta tableMeta) { + EntityDesc entityDesc = new EntityDesc(); + doName(tableMeta, entityDesc); + doTable(tableMeta, entityDesc); + doAttributeDesc(tableMeta, entityDesc); + doCompositeUniqueConstraintDesc(tableMeta, entityDesc); + return entityDesc; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescFactoryImpl.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescSetWriterImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescSetWriterImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescSetWriterImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,149 +1,149 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc.impl; - -import java.io.File; -import java.io.IOException; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.entity.io.convensition.PersistenceConvention; -import org.jiemamy.entity.io.convensition.impl.PersistenceConventionImpl; -import org.jiemamy.entity.io.gen.desc.EntityDesc; -import org.jiemamy.entity.io.gen.desc.EntityDescSetWriter; -import org.jiemamy.entity.io.gen.desc.EntityDescSetWriterContext; -import org.jiemamy.entity.io.gen.desc.EntitySetDesc; -import org.jiemamy.entity.io.gen.desc.EntitySetDescFactory; -import org.jiemamy.entity.io.gen.generator.GenerateException; -import org.jiemamy.entity.io.gen.generator.Generator; -import org.jiemamy.entity.io.gen.generator.impl.GeneratorContextImpl; -import org.jiemamy.entity.io.gen.generator.impl.GeneratorImpl; -import org.jiemamy.entity.io.gen.model.AssociationModelFactory; -import org.jiemamy.entity.io.gen.model.AttributeModelFactory; -import org.jiemamy.entity.io.gen.model.CompositeUniqueConstraintModelFactory; -import org.jiemamy.entity.io.gen.model.EntityModel; -import org.jiemamy.entity.io.gen.model.EntityModelFactory; -import org.jiemamy.entity.io.gen.model.impl.AssociationModelFactoryImpl; -import org.jiemamy.entity.io.gen.model.impl.AttributeModelFactoryImpl; -import org.jiemamy.entity.io.gen.model.impl.CompositeUniqueConstraintModelFactoryImpl; -import org.jiemamy.entity.io.gen.model.impl.EntityModelFactoryImpl; -import org.jiemamy.entity.io.utils.FileUtil; -import org.jiemamy.utils.ClassUtil; -import org.jiemamy.utils.StringUtil; - -/** - * EntityMetaWriterContextの実装クラス。 - * - * @author j5ik2o - */ -public class EntityDescSetWriterImpl implements EntityDescSetWriter { - - private Generator generator; - - private EntityDescSetWriterContext entityDescSetWriterContext; - - private EntityModelFactory entityModelFactory; - - private EntitySetDescFactory entitySetDescFactory; - - - /** - * インスタンスを生成する。 - * - * @param entityMetaWriterContext {@link EntityMetaWriterContext} - * @throws IdentityNotSupportedException - * @throws IOException - */ - public EntityDescSetWriterImpl(EntityDescSetWriterContext entityDescSetWriterContext) - throws IdentityNotSupportedException, IOException { - Validate.notNull(entityDescSetWriterContext); - Validate.notNull(entityDescSetWriterContext.getDbTableMetaReader()); - Validate.notNull(entityDescSetWriterContext.getJavaSrcFileEncoding()); - Validate.notNull(entityDescSetWriterContext.getTemplateName()); - this.entityDescSetWriterContext = entityDescSetWriterContext; - PersistenceConvention persistenceConvention = entityDescSetWriterContext.getPersistenceConvention(); - if (persistenceConvention == null) { - persistenceConvention = new PersistenceConventionImpl(); - } - entityModelFactory = createEntityModelFactory(entityDescSetWriterContext, persistenceConvention); - entitySetDescFactory = createEntitySetDescFactory(entityDescSetWriterContext, persistenceConvention); - } - - private EntityModelFactory createEntityModelFactory(EntityDescSetWriterContext entityDescSetWriterContext, - PersistenceConvention persistenceConvention) { - AttributeModelFactory attributeModelFactory = - new AttributeModelFactoryImpl(persistenceConvention, entityDescSetWriterContext.isShowColumnName(), - entityDescSetWriterContext.isShowColumnDefinition(), entityDescSetWriterContext - .isUseTemporalType()); - AssociationModelFactory associationModelFactory = - new AssociationModelFactoryImpl(entityDescSetWriterContext.isShowJoinColumn()); - CompositeUniqueConstraintModelFactory compositeUniqueConstraintModelFactory = - new CompositeUniqueConstraintModelFactoryImpl(); - EntityModelFactory result = - new EntityModelFactoryImpl(ClassUtil.concatName(entityDescSetWriterContext.getRootPackageName(), - entityDescSetWriterContext.getEntityPackageName()), entityDescSetWriterContext - .getEntitySuperClass(), attributeModelFactory, associationModelFactory, - compositeUniqueConstraintModelFactory, entityDescSetWriterContext.isUseAccessor(), - entityDescSetWriterContext.isApplyDbCommentToJava(), entityDescSetWriterContext - .isShowCatalogName(), entityDescSetWriterContext.isShowSchemaName(), - entityDescSetWriterContext.isShowTableName()); - return result; - } - - private EntitySetDescFactory createEntitySetDescFactory(EntityDescSetWriterContext entityDescSetWriterContext, - PersistenceConvention persistenceConvention) throws IdentityNotSupportedException { - EntitySetDescFactory result = - new EntitySetDescFactoryImpl(entityDescSetWriterContext.getDbTableMetaReader(), persistenceConvention, - entityDescSetWriterContext.getDialect(), entityDescSetWriterContext - .getVersionColumnNamePattern(), entityDescSetWriterContext.getPluralFormFile(), - entityDescSetWriterContext.getIdGenerationType(), entityDescSetWriterContext.getInitialValue(), - entityDescSetWriterContext.getAllocationSize()); - return result; - } - - public void write() throws IOException { - generator = - new GeneratorImpl(entityDescSetWriterContext.getTemplateFileEncoding(), entityDescSetWriterContext - .getTemplateFilePrimaryDir()); - GeneratorContextImpl context = new GeneratorContextImpl(); - context.setEncoding(entityDescSetWriterContext.getJavaSrcFileEncoding()); - context.setOverwrite(entityDescSetWriterContext.isOverwrite()); - context.setTemplateName(entityDescSetWriterContext.getTemplateName()); - - String packageName = - ClassUtil.concatName(entityDescSetWriterContext.getRootPackageName(), entityDescSetWriterContext - .getEntityPackageName()); - EntitySetDesc entitySetDesc = entitySetDescFactory.getEntitySetDesc(); - for (EntityDesc entityDesc : entitySetDesc.getEntityDescList()) { - File file = - FileUtil.createJavaFile(entityDescSetWriterContext.getJavaSrcFileDestDir(), packageName, StringUtil - .camelize(entityDesc.getName())); - context.setFile(file); - EntityModel entityModel = entityModelFactory.getEntityModel(entityDesc); - context.setModel(entityModel); - try { - generator.generate(context); - } catch (GenerateException e) { - throw new IOException(); - } - } - - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc.impl; + +import java.io.File; +import java.io.IOException; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.entity.io.convensition.PersistenceConvention; +import org.jiemamy.entity.io.convensition.impl.PersistenceConventionImpl; +import org.jiemamy.entity.io.gen.desc.EntityDesc; +import org.jiemamy.entity.io.gen.desc.EntityDescSetWriter; +import org.jiemamy.entity.io.gen.desc.EntityDescSetWriterContext; +import org.jiemamy.entity.io.gen.desc.EntitySetDesc; +import org.jiemamy.entity.io.gen.desc.EntitySetDescFactory; +import org.jiemamy.entity.io.gen.generator.GenerateException; +import org.jiemamy.entity.io.gen.generator.Generator; +import org.jiemamy.entity.io.gen.generator.impl.GeneratorContextImpl; +import org.jiemamy.entity.io.gen.generator.impl.GeneratorImpl; +import org.jiemamy.entity.io.gen.model.AssociationModelFactory; +import org.jiemamy.entity.io.gen.model.AttributeModelFactory; +import org.jiemamy.entity.io.gen.model.CompositeUniqueConstraintModelFactory; +import org.jiemamy.entity.io.gen.model.EntityModel; +import org.jiemamy.entity.io.gen.model.EntityModelFactory; +import org.jiemamy.entity.io.gen.model.impl.AssociationModelFactoryImpl; +import org.jiemamy.entity.io.gen.model.impl.AttributeModelFactoryImpl; +import org.jiemamy.entity.io.gen.model.impl.CompositeUniqueConstraintModelFactoryImpl; +import org.jiemamy.entity.io.gen.model.impl.EntityModelFactoryImpl; +import org.jiemamy.entity.io.utils.FileUtil; +import org.jiemamy.utils.ClassUtil; +import org.jiemamy.utils.StringUtil; + +/** + * EntityMetaWriterContextの実装クラス。 + * + * @author j5ik2o + */ +public class EntityDescSetWriterImpl implements EntityDescSetWriter { + + private Generator generator; + + private EntityDescSetWriterContext entityDescSetWriterContext; + + private EntityModelFactory entityModelFactory; + + private EntitySetDescFactory entitySetDescFactory; + + + /** + * インスタンスを生成する。 + * + * @param entityMetaWriterContext {@link EntityMetaWriterContext} + * @throws IdentityNotSupportedException + * @throws IOException + */ + public EntityDescSetWriterImpl(EntityDescSetWriterContext entityDescSetWriterContext) + throws IdentityNotSupportedException, IOException { + Validate.notNull(entityDescSetWriterContext); + Validate.notNull(entityDescSetWriterContext.getDbTableMetaReader()); + Validate.notNull(entityDescSetWriterContext.getJavaSrcFileEncoding()); + Validate.notNull(entityDescSetWriterContext.getTemplateName()); + this.entityDescSetWriterContext = entityDescSetWriterContext; + PersistenceConvention persistenceConvention = entityDescSetWriterContext.getPersistenceConvention(); + if (persistenceConvention == null) { + persistenceConvention = new PersistenceConventionImpl(); + } + entityModelFactory = createEntityModelFactory(entityDescSetWriterContext, persistenceConvention); + entitySetDescFactory = createEntitySetDescFactory(entityDescSetWriterContext, persistenceConvention); + } + + private EntityModelFactory createEntityModelFactory(EntityDescSetWriterContext entityDescSetWriterContext, + PersistenceConvention persistenceConvention) { + AttributeModelFactory attributeModelFactory = + new AttributeModelFactoryImpl(persistenceConvention, entityDescSetWriterContext.isShowColumnName(), + entityDescSetWriterContext.isShowColumnDefinition(), entityDescSetWriterContext + .isUseTemporalType()); + AssociationModelFactory associationModelFactory = + new AssociationModelFactoryImpl(entityDescSetWriterContext.isShowJoinColumn()); + CompositeUniqueConstraintModelFactory compositeUniqueConstraintModelFactory = + new CompositeUniqueConstraintModelFactoryImpl(); + EntityModelFactory result = + new EntityModelFactoryImpl(ClassUtil.concatName(entityDescSetWriterContext.getRootPackageName(), + entityDescSetWriterContext.getEntityPackageName()), entityDescSetWriterContext + .getEntitySuperClass(), attributeModelFactory, associationModelFactory, + compositeUniqueConstraintModelFactory, entityDescSetWriterContext.isUseAccessor(), + entityDescSetWriterContext.isApplyDbCommentToJava(), entityDescSetWriterContext + .isShowCatalogName(), entityDescSetWriterContext.isShowSchemaName(), + entityDescSetWriterContext.isShowTableName()); + return result; + } + + private EntitySetDescFactory createEntitySetDescFactory(EntityDescSetWriterContext entityDescSetWriterContext, + PersistenceConvention persistenceConvention) throws IdentityNotSupportedException { + EntitySetDescFactory result = + new EntitySetDescFactoryImpl(entityDescSetWriterContext.getDbTableMetaReader(), persistenceConvention, + entityDescSetWriterContext.getDialect(), entityDescSetWriterContext + .getVersionColumnNamePattern(), entityDescSetWriterContext.getPluralFormFile(), + entityDescSetWriterContext.getIdGenerationType(), entityDescSetWriterContext.getInitialValue(), + entityDescSetWriterContext.getAllocationSize()); + return result; + } + + public void write() throws IOException { + generator = + new GeneratorImpl(entityDescSetWriterContext.getTemplateFileEncoding(), entityDescSetWriterContext + .getTemplateFilePrimaryDir()); + GeneratorContextImpl context = new GeneratorContextImpl(); + context.setEncoding(entityDescSetWriterContext.getJavaSrcFileEncoding()); + context.setOverwrite(entityDescSetWriterContext.isOverwrite()); + context.setTemplateName(entityDescSetWriterContext.getTemplateName()); + + String packageName = + ClassUtil.concatName(entityDescSetWriterContext.getRootPackageName(), entityDescSetWriterContext + .getEntityPackageName()); + EntitySetDesc entitySetDesc = entitySetDescFactory.getEntitySetDesc(); + for (EntityDesc entityDesc : entitySetDesc.getEntityDescList()) { + File file = + FileUtil.createJavaFile(entityDescSetWriterContext.getJavaSrcFileDestDir(), packageName, StringUtil + .camelize(entityDesc.getName())); + context.setFile(file); + EntityModel entityModel = entityModelFactory.getEntityModel(entityDesc); + context.setModel(entityModel); + try { + generator.generate(context); + } catch (GenerateException e) { + throw new IOException(); + } + } + + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescSetWriterImpl.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntitySetDescFactoryImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntitySetDescFactoryImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntitySetDescFactoryImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,207 +1,207 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc.impl; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.regex.Pattern; - -import javax.persistence.GenerationType; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.entity.io.convensition.PersistenceConvention; -import org.jiemamy.entity.io.gen.desc.AttributeDescFactory; -import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDescFactory; -import org.jiemamy.entity.io.gen.desc.EntityDesc; -import org.jiemamy.entity.io.gen.desc.EntityDescFactory; -import org.jiemamy.entity.io.gen.desc.EntitySetDesc; -import org.jiemamy.entity.io.gen.desc.EntitySetDescFactory; -import org.jiemamy.entity.io.gen.dialect.GenDialect; -import org.jiemamy.entity.io.gen.meta.DbForeignKeyMeta; -import org.jiemamy.entity.io.gen.meta.DbTableMeta; -import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; - -/** - * {@link EntitySetDescFactory}の実装クラスです。 - * - * @author j5ik2o - */ -public class EntitySetDescFactoryImpl implements EntitySetDescFactory { - - /** テーブルメタデータのリーダ */ - protected DbTableMetaReader dbTableMetaReader; - - /** バージョンカラム名のパターン */ - protected Pattern versionColumnNamePattern; - - /** 単語を複数系に変換するための辞書ファイル、使用しない場合は{@code null} */ - protected File pluralFormFile; - - /** エンティティの識別子の生成方法を示す列挙型 、生成しない場合は{@code null} */ - protected GenerationType generationType; - - /** エンティティの識別子の初期値、指定しない場合は{@code null} */ - protected Integer initialValue; - - /** エンティティの識別子の割り当てサイズ、指定しない場合は{@code null} */ - protected Integer allocationSize; - - /** エンティティ記述のファクトリ */ - protected EntityDescFactory entityDescFactory; - - /** 方言 */ - protected GenDialect dialect; - - private PersistenceConvention persistenceConvention; - - - /** - * インスタンスを構築する。 - * - * @param dbTableMetaReader テーブルメタデータのリーダ - * @param persistenceConvention 永続化層の命名規約 - * @param dialect SQL方言 - * @param versionColumnNamePattern バージョンカラム名のパターン - * @param pluralFormFile 単語を複数系に変換するための辞書ファイル、使用しない場合は{@code null} - * @param generationType エンティティの識別子の生成方法を示す列挙型 、生成しない場合は{@code null} - * @param initialValue エンティティの識別子の初期値、指定しない場合は{@code null} - * @param allocationSize エンティティの識別子の割り当てサイズ、指定しない場合は{@code null} - * @throws IdentityNotSupportedException IDENTITYがサポートされていない場合 - */ - public EntitySetDescFactoryImpl(DbTableMetaReader dbTableMetaReader, PersistenceConvention persistenceConvention, - GenDialect dialect, Pattern versionColumnNamePattern, File pluralFormFile, GenerationType generationType, - Integer initialValue, Integer allocationSize) throws IdentityNotSupportedException { - Validate.notNull(dbTableMetaReader); - Validate.notNull(persistenceConvention); - Validate.notNull(dialect); - Validate.notNull(versionColumnNamePattern); - this.dbTableMetaReader = dbTableMetaReader; - this.persistenceConvention = persistenceConvention; - this.dialect = dialect; - this.versionColumnNamePattern = versionColumnNamePattern; - this.pluralFormFile = pluralFormFile; - this.generationType = generationType; - this.initialValue = initialValue; - this.allocationSize = allocationSize; - entityDescFactory = createEntityDescFactory(); - } - - /** - * 関連のリゾルバを作成する。 - * - * @param entitySetDesc エンティティ集合記述 - * @param pluralFormDictinary 単語を複数形に変換するための辞書 - * @return 関連のリゾルバ - */ - protected AssociationResolver createAssociationResolver(EntitySetDesc entitySetDesc, - PluralFormDictinary pluralFormDictinary) { - return new AssociationResolver(entitySetDesc, pluralFormDictinary); - } - - /** - * {@link EntityDescFactory}の実装を作成する。 - * - * @return {@link EntityDescFactory}の実装 - * @throws IdentityNotSupportedException IDENTITYがサポートされていない場合 - */ - protected EntityDescFactory createEntityDescFactory() throws IdentityNotSupportedException { - AttributeDescFactory attributeDescFactory = - new AttributeDescFactoryImpl(persistenceConvention, dialect, versionColumnNamePattern, generationType, - initialValue, allocationSize); - CompositeUniqueConstraintDescFactory compositeUniqueConstraintDescFactory = - new CompositeUniqueConstraintDescFactoryImpl(); - return new EntityDescFactoryImpl(persistenceConvention, attributeDescFactory, - compositeUniqueConstraintDescFactory); - } - - /** - * 単語を複数形に変換するための辞書を作成する。 - * - * @return 単語を複数形に変換するための辞書 - * @throws IOException 入出力が失敗した場合 - */ - protected PluralFormDictinary createPluralFormDictinary() throws IOException { - if (pluralFormFile != null) { - LinkedHashMap<String, String> map = loadPluralFormFile(); - return new PluralFormDictinary(map); - } - return new PluralFormDictinary(); - } - - public EntitySetDesc getEntitySetDesc() throws IOException { - EntitySetDesc entitySetDesc = new EntitySetDesc(); - List<DbTableMeta> dbTableMetaList = dbTableMetaReader.read(); - for (DbTableMeta tableMeta : dbTableMetaList) { - EntityDesc entityDesc = entityDescFactory.getEntityDesc(tableMeta); - entitySetDesc.addEntityDesc(entityDesc); - } - - PluralFormDictinary pluralFormDictinary = createPluralFormDictinary(); - AssociationResolver associationResolver = createAssociationResolver(entitySetDesc, pluralFormDictinary); - for (DbTableMeta tableMeta : dbTableMetaList) { - for (DbForeignKeyMeta fkMeta : tableMeta.getForeignKeyMetaList()) { - associationResolver.resolve(tableMeta, fkMeta); - } - } - return entitySetDesc; - } - - /** - * 辞書ファイルをロードし結果を{@link LinkedHashMap}として取得する。 - * - * @return 正規表現をキー、置換文字列を値とするマップ - * @throws IOException 入出力が失敗した場合 - */ - public LinkedHashMap<String, String> loadPluralFormFile() throws IOException { - LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(); - BufferedReader reader = null; - try { - reader = new BufferedReader(new InputStreamReader(new FileInputStream(pluralFormFile), "UTF-8")); - String line; - while ((line = reader.readLine()) != null) { - if (line.length() == 0) { - continue; - } - char firstChar = line.charAt(0); - if (firstChar == '#' || firstChar == '!') { - continue; - } - int pos = line.indexOf('='); - if (pos < 0) { - continue; - } - String key = line.substring(0, pos); - String value = line.substring(pos + 1, line.length()); - map.put(key, value); - } - } finally { - if (reader != null) { - reader.close(); - } - } - return map; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc.impl; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.regex.Pattern; + +import javax.persistence.GenerationType; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.entity.io.convensition.PersistenceConvention; +import org.jiemamy.entity.io.gen.desc.AttributeDescFactory; +import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDescFactory; +import org.jiemamy.entity.io.gen.desc.EntityDesc; +import org.jiemamy.entity.io.gen.desc.EntityDescFactory; +import org.jiemamy.entity.io.gen.desc.EntitySetDesc; +import org.jiemamy.entity.io.gen.desc.EntitySetDescFactory; +import org.jiemamy.entity.io.gen.dialect.GenDialect; +import org.jiemamy.entity.io.gen.meta.DbForeignKeyMeta; +import org.jiemamy.entity.io.gen.meta.DbTableMeta; +import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; + +/** + * {@link EntitySetDescFactory}の実装クラスです。 + * + * @author j5ik2o + */ +public class EntitySetDescFactoryImpl implements EntitySetDescFactory { + + /** テーブルメタデータのリーダ */ + protected DbTableMetaReader dbTableMetaReader; + + /** バージョンカラム名のパターン */ + protected Pattern versionColumnNamePattern; + + /** 単語を複数系に変換するための辞書ファイル、使用しない場合は{@code null} */ + protected File pluralFormFile; + + /** エンティティの識別子の生成方法を示す列挙型 、生成しない場合は{@code null} */ + protected GenerationType generationType; + + /** エンティティの識別子の初期値、指定しない場合は{@code null} */ + protected Integer initialValue; + + /** エンティティの識別子の割り当てサイズ、指定しない場合は{@code null} */ + protected Integer allocationSize; + + /** エンティティ記述のファクトリ */ + protected EntityDescFactory entityDescFactory; + + /** 方言 */ + protected GenDialect dialect; + + private PersistenceConvention persistenceConvention; + + + /** + * インスタンスを構築する。 + * + * @param dbTableMetaReader テーブルメタデータのリーダ + * @param persistenceConvention 永続化層の命名規約 + * @param dialect SQL方言 + * @param versionColumnNamePattern バージョンカラム名のパターン + * @param pluralFormFile 単語を複数系に変換するための辞書ファイル、使用しない場合は{@code null} + * @param generationType エンティティの識別子の生成方法を示す列挙型 、生成しない場合は{@code null} + * @param initialValue エンティティの識別子の初期値、指定しない場合は{@code null} + * @param allocationSize エンティティの識別子の割り当てサイズ、指定しない場合は{@code null} + * @throws IdentityNotSupportedException IDENTITYがサポートされていない場合 + */ + public EntitySetDescFactoryImpl(DbTableMetaReader dbTableMetaReader, PersistenceConvention persistenceConvention, + GenDialect dialect, Pattern versionColumnNamePattern, File pluralFormFile, GenerationType generationType, + Integer initialValue, Integer allocationSize) throws IdentityNotSupportedException { + Validate.notNull(dbTableMetaReader); + Validate.notNull(persistenceConvention); + Validate.notNull(dialect); + Validate.notNull(versionColumnNamePattern); + this.dbTableMetaReader = dbTableMetaReader; + this.persistenceConvention = persistenceConvention; + this.dialect = dialect; + this.versionColumnNamePattern = versionColumnNamePattern; + this.pluralFormFile = pluralFormFile; + this.generationType = generationType; + this.initialValue = initialValue; + this.allocationSize = allocationSize; + entityDescFactory = createEntityDescFactory(); + } + + /** + * 関連のリゾルバを作成する。 + * + * @param entitySetDesc エンティティ集合記述 + * @param pluralFormDictinary 単語を複数形に変換するための辞書 + * @return 関連のリゾルバ + */ + protected AssociationResolver createAssociationResolver(EntitySetDesc entitySetDesc, + PluralFormDictinary pluralFormDictinary) { + return new AssociationResolver(entitySetDesc, pluralFormDictinary); + } + + /** + * {@link EntityDescFactory}の実装を作成する。 + * + * @return {@link EntityDescFactory}の実装 + * @throws IdentityNotSupportedException IDENTITYがサポートされていない場合 + */ + protected EntityDescFactory createEntityDescFactory() throws IdentityNotSupportedException { + AttributeDescFactory attributeDescFactory = + new AttributeDescFactoryImpl(persistenceConvention, dialect, versionColumnNamePattern, generationType, + initialValue, allocationSize); + CompositeUniqueConstraintDescFactory compositeUniqueConstraintDescFactory = + new CompositeUniqueConstraintDescFactoryImpl(); + return new EntityDescFactoryImpl(persistenceConvention, attributeDescFactory, + compositeUniqueConstraintDescFactory); + } + + /** + * 単語を複数形に変換するための辞書を作成する。 + * + * @return 単語を複数形に変換するための辞書 + * @throws IOException 入出力が失敗した場合 + */ + protected PluralFormDictinary createPluralFormDictinary() throws IOException { + if (pluralFormFile != null) { + LinkedHashMap<String, String> map = loadPluralFormFile(); + return new PluralFormDictinary(map); + } + return new PluralFormDictinary(); + } + + public EntitySetDesc getEntitySetDesc() throws IOException { + EntitySetDesc entitySetDesc = new EntitySetDesc(); + List<DbTableMeta> dbTableMetaList = dbTableMetaReader.read(); + for (DbTableMeta tableMeta : dbTableMetaList) { + EntityDesc entityDesc = entityDescFactory.getEntityDesc(tableMeta); + entitySetDesc.addEntityDesc(entityDesc); + } + + PluralFormDictinary pluralFormDictinary = createPluralFormDictinary(); + AssociationResolver associationResolver = createAssociationResolver(entitySetDesc, pluralFormDictinary); + for (DbTableMeta tableMeta : dbTableMetaList) { + for (DbForeignKeyMeta fkMeta : tableMeta.getForeignKeyMetaList()) { + associationResolver.resolve(tableMeta, fkMeta); + } + } + return entitySetDesc; + } + + /** + * 辞書ファイルをロードし結果を{@link LinkedHashMap}として取得する。 + * + * @return 正規表現をキー、置換文字列を値とするマップ + * @throws IOException 入出力が失敗した場合 + */ + public LinkedHashMap<String, String> loadPluralFormFile() throws IOException { + LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(); + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(new FileInputStream(pluralFormFile), "UTF-8")); + String line; + while ((line = reader.readLine()) != null) { + if (line.length() == 0) { + continue; + } + char firstChar = line.charAt(0); + if (firstChar == '#' || firstChar == '!') { + continue; + } + int pos = line.indexOf('='); + if (pos < 0) { + continue; + } + String key = line.substring(0, pos); + String value = line.substring(pos + 1, line.length()); + map.put(key, value); + } + } finally { + if (reader != null) { + reader.close(); + } + } + return map; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntitySetDescFactoryImpl.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/IdentityNotSupportedException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/IdentityNotSupportedException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/IdentityNotSupportedException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,68 +1,68 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 14, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc.impl; - -/** - * TODO for kato - * - * @author kato - */ - @ SuppressWarnings("serial") -public class IdentityNotSupportedException extends Exception { - - /** - * インスタンスを生成する。 - * - */ - public IdentityNotSupportedException() { - // TODO Auto-generated constructor stub - } - - /** - * インスタンスを生成する。 - * - * @param message - */ - public IdentityNotSupportedException(String message) { - super(message); - // TODO Auto-generated constructor stub - } - - /** - * インスタンスを生成する。 - * - * @param message - * @param cause - */ - public IdentityNotSupportedException(String message, Throwable cause) { - super(message, cause); - // TODO Auto-generated constructor stub - } - - /** - * インスタンスを生成する。 - * - * @param cause - */ - public IdentityNotSupportedException(Throwable cause) { - super(cause); - // TODO Auto-generated constructor stub - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 14, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc.impl; + +/** + * TODO for kato + * + * @author kato + */ + @ SuppressWarnings("serial") +public class IdentityNotSupportedException extends Exception { + + /** + * インスタンスを生成する。 + * + */ + public IdentityNotSupportedException() { + // TODO Auto-generated constructor stub + } + + /** + * インスタンスを生成する。 + * + * @param message + */ + public IdentityNotSupportedException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + /** + * インスタンスを生成する。 + * + * @param message + * @param cause + */ + public IdentityNotSupportedException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + /** + * インスタンスを生成する。 + * + * @param cause + */ + public IdentityNotSupportedException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/IdentityNotSupportedException.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/PluralFormDictinary.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/PluralFormDictinary.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/PluralFormDictinary.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,82 +1,82 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc.impl; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * 単語を複数形に変換するクラスです。 - * - * @author j5ik2o - */ -public class PluralFormDictinary { - - /** {@link Pattern}をキー、置換文字列を値とするマップ */ - protected LinkedHashMap<Pattern, String> patternMap = new LinkedHashMap<Pattern, String>(); - - - /** - * インスタンスを構築する。 - */ - public PluralFormDictinary() { - } - - /** - * インスタンスを構築する。 - * - * @param dictinary 正規表現の文字列をキー、置換文字列を値とするマップ - */ - public PluralFormDictinary(LinkedHashMap<String, String> dictinary) { - for (Map.Entry<String, String> entry : dictinary.entrySet()) { - Pattern pattern = Pattern.compile(entry.getKey()); - patternMap.put(pattern, entry.getValue()); - } - } - - /** - * 単語の複数形を検索する。 - * - * @param word 単語 - * @return 見つかれば単語の複数形、見つからなければ{@code null} - */ - public String lookup(String word) { - for (Map.Entry<Pattern, String> entry : patternMap.entrySet()) { - Pattern pattern = entry.getKey(); - Matcher matcher = pattern.matcher(word); - if (!matcher.matches()) { - continue; - } - matcher.reset(); - StringBuffer buf = new StringBuffer(); - String replacement = entry.getValue(); - for (; matcher.find();) { - matcher.appendReplacement(buf, replacement); - if (matcher.hitEnd()) { - break; - } - } - matcher.appendTail(buf); - return buf.toString(); - } - return null; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc.impl; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 単語を複数形に変換するクラスです。 + * + * @author j5ik2o + */ +public class PluralFormDictinary { + + /** {@link Pattern}をキー、置換文字列を値とするマップ */ + protected LinkedHashMap<Pattern, String> patternMap = new LinkedHashMap<Pattern, String>(); + + + /** + * インスタンスを構築する。 + */ + public PluralFormDictinary() { + } + + /** + * インスタンスを構築する。 + * + * @param dictinary 正規表現の文字列をキー、置換文字列を値とするマップ + */ + public PluralFormDictinary(LinkedHashMap<String, String> dictinary) { + for (Map.Entry<String, String> entry : dictinary.entrySet()) { + Pattern pattern = Pattern.compile(entry.getKey()); + patternMap.put(pattern, entry.getValue()); + } + } + + /** + * 単語の複数形を検索する。 + * + * @param word 単語 + * @return 見つかれば単語の複数形、見つからなければ{@code null} + */ + public String lookup(String word) { + for (Map.Entry<Pattern, String> entry : patternMap.entrySet()) { + Pattern pattern = entry.getKey(); + Matcher matcher = pattern.matcher(word); + if (!matcher.matches()) { + continue; + } + matcher.reset(); + StringBuffer buf = new StringBuffer(); + String replacement = entry.getValue(); + for (; matcher.find();) { + matcher.appendReplacement(buf, replacement); + if (matcher.hitEnd()) { + break; + } + } + matcher.appendTail(buf); + return buf.toString(); + } + return null; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/PluralFormDictinary.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/GenDialect.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/GenDialect.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/GenDialect.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,382 +1,382 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.dialect; - -import javax.persistence.GenerationType; - -/** - * RDBMSごとの方言を扱うインタフェース。 - * - * @author j5ik2o - */ -public interface GenDialect { - - /** - * カラム型。 - * <p> - * データベースのメタデータが返すカラムの型名に対応する。 - * <p> - * <p> - * データベースのメタデータからJavaコードを生成する場合に使用できます。 - * </p> - * - * @author j5ik2o - */ - interface ColumnType { - - /** - * 属性のクラスを取得する。 - * - * @param length 長さ - * @param precision 精度 - * @param scale スケール - * @return 属性のクラス - */ - Class<?> getAttributeClass(int length, int precision, int scale); - - /** - * カラム定義を取得する。 - * - * @param length 長さ - * @param precision 精度 - * @param scale スケール - * @param defaultValue デフォルト値、存在しない場合は{@code null} - * @return カラム定義 - */ - String getColumnDefinition(int length, int precision, int scale, String defaultValue); - - /** - * LOBの場合{@code true} - * - * @return LOBの場合{@code true} - */ - boolean isLob(); - - } - - - /** - * SQLブロックのコンテキスト。 - * - * @author j5ik2o - */ -// interface SqlBlockContext { -// -// /** -// * SQLのキーワードを追加する。 -// * -// * @param keyword SQLのキーワード -// */ -// void addKeyword(String keyword); -// -// /** -// * SQLブロックの内側と判定できる場合{@code true} -// * -// * @return SQLブロックの内側と判定できる場合{@code true} -// */ -// boolean isInSqlBlock(); -// } - /** - * SQLブロックのコンテキストを作成する。 - * - * @return SQLブロックのコンテキスト - */ - //SqlBlockContext createSqlBlockContext(); - /** - * 終了を表すクォートを取得する。 - * - * @return 終了を表すクォート - */ - //String getCloseQuote(); - /** - * カラムのコメントをデータベースから直接取得しマップに詰めて取得する。 - * <p> - * {@link #isJdbcCommentAvailable()}が{@code true}を返す場合に利用できます。 - * </p> - * <p> - * 戻り値のマップのキーは大文字小文字を気にしません。 カラム名に対応するコメントが存在しない、値は{@code null}になります。 - * </p> - * - * @param connection コネクション - * @param catalogName カタログ名 - * @param schemaName スキーマ名 - * @param tableName テーブル名 - * @return 大文字小文字を気にしないカラム名をキー、カラムのコメントを値とするマップ - * @throws SQLException SQL例外が発生した場合 - */ -// Map<String, String> getColumnCommentMap(Connection connection, String catalogName, String schemaName, -// String tableName) throws SQLException; - /** - * カラム型を取得する。 - * - * @param columnTypeName カラムの型名 - * @param sqlType JDBCのSQL型 - * @return カラム型、サポートされていないカラムの型名の場合{@code null} - */ - ColumnType getColumnType(String columnTypeName, int sqlType); - - /** - * デフォルトの{@link GenerationType}を取得する。 - * - * @return デフォルトの{@link GenerationType} - */ - GenerationType getDefaultGenerationType(); - - /** - * デフォルトのスキーマ名を取得する。 - * - * @param userName ユーザー名 - * @return スキーマ名 - */ - //String getDefaultSchemaName(String userName); - /** - * 外部キーを削除する構文を取得する。 - * - * @return 外部キーを削除する構文 - */ - //String getDropForeignKeySyntax(); - /** - * 一意キーを削除する構文を取得する。 - * - * @return 外部キーを削除する構文 - */ - //String getDropUniqueKeySyntax(); - /** - * IDENTITYカラムの定義を取得する。 - * - * @return IDENTITYカラムの定義 - */ - //String getIdentityColumnDefinition(); - /** - * IDENTITYカラムに対するinsertを無効化するステートメントを取得する。 - * - * @param tableName テーブル名 - * @return IDENTITYカラムに対するinsertを無効化するステートメント - */ - //String getIdentityInsertDisableStatement(String tableName); - /** - * IDENTITYカラムに対するinsertを有効化するステートメントを取得する。 - * - * @param tableName テーブル名 - * @return IDENTITYカラムに対するinsertを有効化するステートメント - */ - //String getIdentityInsertEnableStatement(String tableName); - /** - * 名前を取得する。 - * - * @return 名前 - */ - String getName(); - - /** - * 開始を表すクォートを取得する。 - * - * @return 開始を表すクォート - */ - //String getOpenQuote(); - /** - * シーケンス定義の断片を取得する。 - * <p> - * この断片は create sequence 以降に続きます。 - * </p> - * - * @param dataType データタイプ - * @param initialValue 初期値 - * @param allocationSize 割り当てサイズ - * @return シーケンス定義の断片 - */ - //String getSequenceDefinitionFragment(String dataType, long initialValue, int allocationSize); - /** - * シーケンスの値を取得するSQLを取得する。 - * - * @param sequenceName シーケンス名 - * @param allocationSize 割り当てサイズ - * @return シーケンスの値を取得するSQL - */ - //String getSequenceNextValString(String sequenceName, int allocationSize); - /** - * SQLブロックの区切り文字を取得する。 - * - * @return SQLブロックの区切り文字、SQLブロックの区切り文字蛾存在しない場合{@code null} - */ - //String getSqlBlockDelimiter(); - /** - * SQL型を取得する。 - * - * @param sqlType JDBCのSQL型 - * @return SQL型 - * @throws UnsupportedSqlTypeException サポートされていないJDBCのSQL型が渡された場合 - */ - //SqlType getSqlType(int sqlType) throws UnsupportedSqlTypeException; - /** - * SQL型を取得する。 - * - * @param valueTypeProvider - * {@link ValueType}の提供者 - * @param propertyMeta - * プロパティメタデータ - * @return SQL型 - * @throws UnsupportedSqlTypeException - * @throws UnsupportedSqlTypeRuntimeException - * サポートされていないJDBCのSQL型が渡された場合 - */ -// SqlType getSqlType(ValueTypeProvider valueTypeProvider, PropertyMeta propertyMeta) -// throws UnsupportedSqlTypeException; - /** - * テーブルのコメントをデータベースから直接取得する。 - * <p> - * {@link #isJdbcCommentAvailable()}が{@code true}を返す場合に利用できます。 - * </p> - * - * @param connection コネクション - * @param catalogName カタログ名 - * @param schemaName スキーマ名 - * @param tableName テーブル名 - * @return テーブルのコメント、存在しない場合{@code null} - * @throws SQLException SQL例外が発生した場合 - */ - //String getTableComment(Connection connection, String catalogName, String schemaName, String tableName) - // throws SQLException; - /** - * 列の値が自動的に増分される場合{@code true}を取得する。 - * - * @param connection コネクション - * @param catalogName カタログ名 - * @param schemaName スキーマ名 - * @param tableName テーブル名 - * @param columnName カラム名 - * @return 列が自動的に増分される場合{@code true}、そうでない場合{@code false} - * @throws SQLException SQL例外が発生した場合 - */ -// boolean isAutoIncrement(Connection connection, String catalogName, String schemaName, String tableName, -// String columnName) throws SQLException; - /** - * カラムが存在しない例外を表す場合{@code true}を取得する。 - * - * @param throwable 何らかの例外 - * @return カラムが存在しない例外を表す場合{@code true} - */ - //boolean isColumnNotFound(Throwable throwable); - /** - * JDBCのコメント取得機能が利用できる場合{@code true}を取得する。 - * <p> - * JDBCのコメント取得機能が利用できるとは、次のメソッドでREMARKSカラムの値が取得できることを意味する。 - * </p> - * <ul> - * <li>{@link DatabaseMetaData#getTables(String, String, String, String[])}</li> - * <li>{@link DatabaseMetaData#getColumns(String, String, String, String)}</li> - * </ul> - * - * @return JDBCのコメント取得機能が利用できる場合{@code true} - */ - //boolean isJdbcCommentAvailable(); - /** - * シーケンスが存在しない例外を表す場合{@code true}を取得する。 - * - * @param throwable 何らかの例外 - * @return シーケンスが存在しない例外を表す場合{@code true} - */ - //boolean isSequenceNotFound(Throwable throwable); - /** - * テーブルが存在しない例外を表す場合{@code true}を取得する。 - * - * @param throwable 何らかの例外 - * @return テーブルが存在しない例外を表す場合{@code true} - */ - //boolean isTableNotFound(Throwable throwable); - /** - * クォートで囲みます。 - * - * @param value 値 - * @return クォートで囲まれた値 - */ - //String quote(String value); - /** - * CREATE TABLEでコメントをサポートする場合{@code true}を取得する。 - * - * @return コメントをサポートする場合{@code true} - */ - //boolean supportsCommentInCreateTable(); - /** - * COMMENT ONをサポートする場合{@code true}を取得する。 - * - * @return COMMENT ONをサポートする場合{@code true} - */ - //boolean supportsCommentOn(); - /** - * {@link DatabaseMetaData#getIndexInfo(String, String, String, boolean, boolean)} - * をサポートする場合{@code true}を取得する。 - * - * @param catalogName カタログ名 - * @param schemaName スキーマ名 - * @param tableName テーブル名 - * @return {@link DatabaseMetaData#getIndexInfo(String, String, String, boolean, boolean)} - * をサポートする場合{@code true} - */ - //boolean supportsGetIndexInfo(String catalogName, String schemaName, String tableName); - /** - * IDENTITYカラムをサポートしている場合{@code true}を取得する。 - * - * @return IDENTITYカラムをサポートしている場合{@code true} - */ - boolean supportsIdentity(); - - /** - * IDENTITYカラムに対するinsertをサポートしている場合{@code true}を取得する。 - * - * @return IDENTITYカラムに対するinsertをサポートしている場合{@code true} - */ - //boolean supportsIdentityInsert(); - /** - * IDENTITYカラムに対するinsertの有効/無効を制御するステートメントをサポートしている場合{@code true}を取得する。 - * - * @return IDENTITYカラムに対するinsertをサポートしている場合{@code true} - */ - //boolean supportsIdentityInsertControlStatement(); - /** - * NULLが可能な一意制約をサポートしている場合{@code true}を取得する。 - * - * @return NULLが可能な一意制約をサポートしている場合{@code true} - */ - //boolean supportsNullableUnique(); - /** - * 参照整合制約の削除規則をサポートする場合{@code true}を取得する。 - * - * @return 参照整合制約の削除規則をサポートする場合{@code true} - */ - //boolean supportsReferentialDeleteRule(); - /** - * 参照整合制約の更新規則をサポートする場合{@code true}を取得する。 - * - * @return 参照整合制約の更新規則をサポートする場合{@code true} - */ - //boolean supportsReferentialUpdateRule(); - /** - * シーケンスをサポートする場合{@code true}を取得する。 - * - * @return シーケンスをサポートする場合{@code true}、しない場合{@code false} - */ - //boolean supportsSequence(); - /** - * クォートを除去する。 - * - * @param value 値 - * @return クォートが取り除かれた値 - */ - //String unquote(String value); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.dialect; + +import javax.persistence.GenerationType; + +/** + * RDBMSごとの方言を扱うインタフェース。 + * + * @author j5ik2o + */ +public interface GenDialect { + + /** + * カラム型。 + * <p> + * データベースのメタデータが返すカラムの型名に対応する。 + * <p> + * <p> + * データベースのメタデータからJavaコードを生成する場合に使用できます。 + * </p> + * + * @author j5ik2o + */ + interface ColumnType { + + /** + * 属性のクラスを取得する。 + * + * @param length 長さ + * @param precision 精度 + * @param scale スケール + * @return 属性のクラス + */ + Class<?> getAttributeClass(int length, int precision, int scale); + + /** + * カラム定義を取得する。 + * + * @param length 長さ + * @param precision 精度 + * @param scale スケール + * @param defaultValue デフォルト値、存在しない場合は{@code null} + * @return カラム定義 + */ + String getColumnDefinition(int length, int precision, int scale, String defaultValue); + + /** + * LOBの場合{@code true} + * + * @return LOBの場合{@code true} + */ + boolean isLob(); + + } + + + /** + * SQLブロックのコンテキスト。 + * + * @author j5ik2o + */ +// interface SqlBlockContext { +// +// /** +// * SQLのキーワードを追加する。 +// * +// * @param keyword SQLのキーワード +// */ +// void addKeyword(String keyword); +// +// /** +// * SQLブロックの内側と判定できる場合{@code true} +// * +// * @return SQLブロックの内側と判定できる場合{@code true} +// */ +// boolean isInSqlBlock(); +// } + /** + * SQLブロックのコンテキストを作成する。 + * + * @return SQLブロックのコンテキスト + */ + //SqlBlockContext createSqlBlockContext(); + /** + * 終了を表すクォートを取得する。 + * + * @return 終了を表すクォート + */ + //String getCloseQuote(); + /** + * カラムのコメントをデータベースから直接取得しマップに詰めて取得する。 + * <p> + * {@link #isJdbcCommentAvailable()}が{@code true}を返す場合に利用できます。 + * </p> + * <p> + * 戻り値のマップのキーは大文字小文字を気にしません。 カラム名に対応するコメントが存在しない、値は{@code null}になります。 + * </p> + * + * @param connection コネクション + * @param catalogName カタログ名 + * @param schemaName スキーマ名 + * @param tableName テーブル名 + * @return 大文字小文字を気にしないカラム名をキー、カラムのコメントを値とするマップ + * @throws SQLException SQL例外が発生した場合 + */ +// Map<String, String> getColumnCommentMap(Connection connection, String catalogName, String schemaName, +// String tableName) throws SQLException; + /** + * カラム型を取得する。 + * + * @param columnTypeName カラムの型名 + * @param sqlType JDBCのSQL型 + * @return カラム型、サポートされていないカラムの型名の場合{@code null} + */ + ColumnType getColumnType(String columnTypeName, int sqlType); + + /** + * デフォルトの{@link GenerationType}を取得する。 + * + * @return デフォルトの{@link GenerationType} + */ + GenerationType getDefaultGenerationType(); + + /** + * デフォルトのスキーマ名を取得する。 + * + * @param userName ユーザー名 + * @return スキーマ名 + */ + //String getDefaultSchemaName(String userName); + /** + * 外部キーを削除する構文を取得する。 + * + * @return 外部キーを削除する構文 + */ + //String getDropForeignKeySyntax(); + /** + * 一意キーを削除する構文を取得する。 + * + * @return 外部キーを削除する構文 + */ + //String getDropUniqueKeySyntax(); + /** + * IDENTITYカラムの定義を取得する。 + * + * @return IDENTITYカラムの定義 + */ + //String getIdentityColumnDefinition(); + /** + * IDENTITYカラムに対するinsertを無効化するステートメントを取得する。 + * + * @param tableName テーブル名 + * @return IDENTITYカラムに対するinsertを無効化するステートメント + */ + //String getIdentityInsertDisableStatement(String tableName); + /** + * IDENTITYカラムに対するinsertを有効化するステートメントを取得する。 + * + * @param tableName テーブル名 + * @return IDENTITYカラムに対するinsertを有効化するステートメント + */ + //String getIdentityInsertEnableStatement(String tableName); + /** + * 名前を取得する。 + * + * @return 名前 + */ + String getName(); + + /** + * 開始を表すクォートを取得する。 + * + * @return 開始を表すクォート + */ + //String getOpenQuote(); + /** + * シーケンス定義の断片を取得する。 + * <p> + * この断片は create sequence 以降に続きます。 + * </p> + * + * @param dataType データタイプ + * @param initialValue 初期値 + * @param allocationSize 割り当てサイズ + * @return シーケンス定義の断片 + */ + //String getSequenceDefinitionFragment(String dataType, long initialValue, int allocationSize); + /** + * シーケンスの値を取得するSQLを取得する。 + * + * @param sequenceName シーケンス名 + * @param allocationSize 割り当てサイズ + * @return シーケンスの値を取得するSQL + */ + //String getSequenceNextValString(String sequenceName, int allocationSize); + /** + * SQLブロックの区切り文字を取得する。 + * + * @return SQLブロックの区切り文字、SQLブロックの区切り文字蛾存在しない場合{@code null} + */ + //String getSqlBlockDelimiter(); + /** + * SQL型を取得する。 + * + * @param sqlType JDBCのSQL型 + * @return SQL型 + * @throws UnsupportedSqlTypeException サポートされていないJDBCのSQL型が渡された場合 + */ + //SqlType getSqlType(int sqlType) throws UnsupportedSqlTypeException; + /** + * SQL型を取得する。 + * + * @param valueTypeProvider + * {@link ValueType}の提供者 + * @param propertyMeta + * プロパティメタデータ + * @return SQL型 + * @throws UnsupportedSqlTypeException + * @throws UnsupportedSqlTypeRuntimeException + * サポートされていないJDBCのSQL型が渡された場合 + */ +// SqlType getSqlType(ValueTypeProvider valueTypeProvider, PropertyMeta propertyMeta) +// throws UnsupportedSqlTypeException; + /** + * テーブルのコメントをデータベースから直接取得する。 + * <p> + * {@link #isJdbcCommentAvailable()}が{@code true}を返す場合に利用できます。 + * </p> + * + * @param connection コネクション + * @param catalogName カタログ名 + * @param schemaName スキーマ名 + * @param tableName テーブル名 + * @return テーブルのコメント、存在しない場合{@code null} + * @throws SQLException SQL例外が発生した場合 + */ + //String getTableComment(Connection connection, String catalogName, String schemaName, String tableName) + // throws SQLException; + /** + * 列の値が自動的に増分される場合{@code true}を取得する。 + * + * @param connection コネクション + * @param catalogName カタログ名 + * @param schemaName スキーマ名 + * @param tableName テーブル名 + * @param columnName カラム名 + * @return 列が自動的に増分される場合{@code true}、そうでない場合{@code false} + * @throws SQLException SQL例外が発生した場合 + */ +// boolean isAutoIncrement(Connection connection, String catalogName, String schemaName, String tableName, +// String columnName) throws SQLException; + /** + * カラムが存在しない例外を表す場合{@code true}を取得する。 + * + * @param throwable 何らかの例外 + * @return カラムが存在しない例外を表す場合{@code true} + */ + //boolean isColumnNotFound(Throwable throwable); + /** + * JDBCのコメント取得機能が利用できる場合{@code true}を取得する。 + * <p> + * JDBCのコメント取得機能が利用できるとは、次のメソッドでREMARKSカラムの値が取得できることを意味する。 + * </p> + * <ul> + * <li>{@link DatabaseMetaData#getTables(String, String, String, String[])}</li> + * <li>{@link DatabaseMetaData#getColumns(String, String, String, String)}</li> + * </ul> + * + * @return JDBCのコメント取得機能が利用できる場合{@code true} + */ + //boolean isJdbcCommentAvailable(); + /** + * シーケンスが存在しない例外を表す場合{@code true}を取得する。 + * + * @param throwable 何らかの例外 + * @return シーケンスが存在しない例外を表す場合{@code true} + */ + //boolean isSequenceNotFound(Throwable throwable); + /** + * テーブルが存在しない例外を表す場合{@code true}を取得する。 + * + * @param throwable 何らかの例外 + * @return テーブルが存在しない例外を表す場合{@code true} + */ + //boolean isTableNotFound(Throwable throwable); + /** + * クォートで囲みます。 + * + * @param value 値 + * @return クォートで囲まれた値 + */ + //String quote(String value); + /** + * CREATE TABLEでコメントをサポートする場合{@code true}を取得する。 + * + * @return コメントをサポートする場合{@code true} + */ + //boolean supportsCommentInCreateTable(); + /** + * COMMENT ONをサポートする場合{@code true}を取得する。 + * + * @return COMMENT ONをサポートする場合{@code true} + */ + //boolean supportsCommentOn(); + /** + * {@link DatabaseMetaData#getIndexInfo(String, String, String, boolean, boolean)} + * をサポートする場合{@code true}を取得する。 + * + * @param catalogName カタログ名 + * @param schemaName スキーマ名 + * @param tableName テーブル名 + * @return {@link DatabaseMetaData#getIndexInfo(String, String, String, boolean, boolean)} + * をサポートする場合{@code true} + */ + //boolean supportsGetIndexInfo(String catalogName, String schemaName, String tableName); + /** + * IDENTITYカラムをサポートしている場合{@code true}を取得する。 + * + * @return IDENTITYカラムをサポートしている場合{@code true} + */ + boolean supportsIdentity(); + + /** + * IDENTITYカラムに対するinsertをサポートしている場合{@code true}を取得する。 + * + * @return IDENTITYカラムに対するinsertをサポートしている場合{@code true} + */ + //boolean supportsIdentityInsert(); + /** + * IDENTITYカラムに対するinsertの有効/無効を制御するステートメントをサポートしている場合{@code true}を取得する。 + * + * @return IDENTITYカラムに対するinsertをサポートしている場合{@code true} + */ + //boolean supportsIdentityInsertControlStatement(); + /** + * NULLが可能な一意制約をサポートしている場合{@code true}を取得する。 + * + * @return NULLが可能な一意制約をサポートしている場合{@code true} + */ + //boolean supportsNullableUnique(); + /** + * 参照整合制約の削除規則をサポートする場合{@code true}を取得する。 + * + * @return 参照整合制約の削除規則をサポートする場合{@code true} + */ + //boolean supportsReferentialDeleteRule(); + /** + * 参照整合制約の更新規則をサポートする場合{@code true}を取得する。 + * + * @return 参照整合制約の更新規則をサポートする場合{@code true} + */ + //boolean supportsReferentialUpdateRule(); + /** + * シーケンスをサポートする場合{@code true}を取得する。 + * + * @return シーケンスをサポートする場合{@code true}、しない場合{@code false} + */ + //boolean supportsSequence(); + /** + * クォートを除去する。 + * + * @param value 値 + * @return クォートが取り除かれた値 + */ + //String unquote(String value); +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/GenDialect.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/SqlType.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/SqlType.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/SqlType.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,58 +1,58 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.dialect; - -import java.sql.Types; - -import org.jiemamy.entity.io.utils.ColumnUtil; - -/** - * SQL型です。 - * <p> - * JDBCのSQL型、つまり{@link Types}の定数に対応する。 - * </p> - * - * @author j5ik2o - */ -public class SqlType { - - private String dataType; - - - /** - * インスタンスを生成する。 - * - * @param dataType データタイプ名 - */ - public SqlType(String dataType) { - this.dataType = dataType; - } - - /** - * データ型を取得する。 - * - * @param length 長さ - * @param precision 精度 - * @param scale スケール - * @param identity IDENTITYカラムの場合{@code true} - * @return データ型 - */ - public String getDataType(int length, int precision, int scale, boolean identity) { - return ColumnUtil.formatDataType(dataType, length, precision, scale); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.dialect; + +import java.sql.Types; + +import org.jiemamy.entity.io.utils.ColumnUtil; + +/** + * SQL型です。 + * <p> + * JDBCのSQL型、つまり{@link Types}の定数に対応する。 + * </p> + * + * @author j5ik2o + */ +public class SqlType { + + private String dataType; + + + /** + * インスタンスを生成する。 + * + * @param dataType データタイプ名 + */ + public SqlType(String dataType) { + this.dataType = dataType; + } + + /** + * データ型を取得する。 + * + * @param length 長さ + * @param precision 精度 + * @param scale スケール + * @param identity IDENTITYカラムの場合{@code true} + * @return データ型 + */ + public String getDataType(int length, int precision, int scale, boolean identity) { + return ColumnUtil.formatDataType(dataType, length, precision, scale); + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/SqlType.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/StandardGenDialect.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/StandardGenDialect.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/StandardGenDialect.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,503 +1,503 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.dialect; - -import java.math.BigDecimal; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.sql.Types; -import java.util.HashMap; -import java.util.Map; - -import javax.persistence.GenerationType; - -import org.jiemamy.entity.io.utils.CaseInsensitiveMap; -import org.jiemamy.entity.io.utils.ColumnUtil; - -/** - * 標準的な方言をあつかうクラスです。 - * - * @author j5ik2o - */ -public class StandardGenDialect implements GenDialect { - - /** - * 標準の{@link ColumnType}の実装クラスです。 - * - * @author j5ik2o - */ - public static class StandardColumnType implements ColumnType { - - private static final StandardColumnType BIGINT = new StandardColumnType("bigint", Long.class); - - private static final StandardColumnType BINARY = new StandardColumnType("binary", byte[].class); - - private static final StandardColumnType BIT = new StandardColumnType("bit", Boolean.class); - - private static final StandardColumnType BLOB = new StandardColumnType("blob", byte[].class, true); - - private static final StandardColumnType BOOLEAN = new StandardColumnType("boolean", Boolean.class); - - private static final StandardColumnType CHAR = new StandardColumnType("char($l)", String.class); - - private static final StandardColumnType CLOB = new StandardColumnType("clob", String.class, true); - - private static final StandardColumnType DATE = new StandardColumnType("date", java.sql.Date.class); - - private static final StandardColumnType DECIMAL = new StandardColumnType("decimal", BigDecimal.class); - - private static final StandardColumnType DOUBLE = new StandardColumnType("double", Double.class); - - private static final StandardColumnType FLOAT = new StandardColumnType("float", Float.class); - - private static final StandardColumnType INTEGER = new StandardColumnType("integer", Integer.class); - - private static final StandardColumnType LONGVARBINARY = new StandardColumnType("longvarbinary", byte[].class); - - private static final StandardColumnType LONGVARCHAR = new StandardColumnType("longvarchar", String.class); - - private static final StandardColumnType NUMERIC = new StandardColumnType("numeric", BigDecimal.class); - - private static final StandardColumnType REAL = new StandardColumnType("real", Float.class); - - private static final StandardColumnType SMALLINT = new StandardColumnType("smallint", Short.class); - - private static final StandardColumnType TIME = new StandardColumnType("time", java.sql.Time.class); - - private static final StandardColumnType TIMESTAMP = new StandardColumnType("timestamp", Timestamp.class); - - private static final StandardColumnType TINYINT = new StandardColumnType("tinyint", Short.class); - - private static final StandardColumnType VARBINARY = new StandardColumnType("varbinary($l)", byte[].class); - - private static final StandardColumnType VARCHAR = new StandardColumnType("varchar($l)", String.class); - - /** カラム定義 */ - protected String dataType; - - /** 属性のクラス */ - protected Class<?> attributeClass; - - /** LOBの場合{@code true} */ - protected boolean lob; - - - /** - * インスタンスを構築する。 - * - * @param dataType データ型 - * @param attributeClass 属性のクラス - */ - protected StandardColumnType(String dataType, Class<?> attributeClass) { - this(dataType, attributeClass, false); - } - - /** - * インスタンスを構築する。 - * - * @param dataType カラム定義 - * @param attributeClass 属性のクラス - * @param lob LOBの場合{@code true} - */ - protected StandardColumnType(String dataType, Class<?> attributeClass, boolean lob) { - this.dataType = dataType; - this.attributeClass = attributeClass; - this.lob = lob; - } - - public Class<?> getAttributeClass(int length, int precision, int scale) { - return attributeClass; - } - - public String getColumnDefinition(int length, int precision, int scale, String defaultValue) { - String completeDataType = ColumnUtil.formatDataType(dataType, length, precision, scale); - return getColumnDefinitionInternal(completeDataType, defaultValue); - } - - /** - * カラム定義を取得する。 - * - * @param completeDataType 完全なデータ型 - * @param defaultValue デフォルト値、存在しない場合は{@code null} - * @return カラム定義 - */ - protected String getColumnDefinitionInternal(String completeDataType, String defaultValue) { - if (defaultValue == null) { - return completeDataType; - } - return completeDataType + " default " + defaultValue; - } - - public boolean isLob() { - return lob; - } - - } - - - /** - * 標準の{@link StandardColumnType}の実装クラスです。 - * - * @author j5ik2o - */ -// public static class StandardSqlBlockContext implements SqlBlockContext { -// -// /** SQLブロックの開始を表すキーワードの連なりのリスト */ -// protected List<List<String>> sqlBlockStartKeywordsList = new ArrayList<List<String>>(); -// -// /** 追加されたキーワードの連なり */ -// protected List<String> keywords = new ArrayList<String>(); -// -// /** SQLブロックの内側の場合{@code true} */ -// protected boolean inSqlBlock; -// -// -// public void addKeyword(String keyword) { -// if (!inSqlBlock) { -// keywords.add(keyword); -// check(); -// } -// } -// -// /** -// * ブロックの内側かどうかチェックする。 -// */ -// protected void check() { -// for (List<String> startKeywords : sqlBlockStartKeywordsList) { -// if (startKeywords.size() > keywords.size()) { -// continue; -// } -// for (int i = 0; i < startKeywords.size(); i++) { -// String word1 = startKeywords.get(i); -// String word2 = keywords.get(i); -// inSqlBlock = word1.equalsIgnoreCase(word2); -// if (!inSqlBlock) { -// break; -// } -// } -// if (inSqlBlock) { -// break; -// } -// } -// } -// -// public boolean isInSqlBlock() { -// return inSqlBlock; -// } -// } - /** SQL型をキー、{@link SqlType}を値とするマップ */ - protected Map<Integer, SqlType> sqlTypeMap = new HashMap<Integer, SqlType>(); - - /** カラムの型名をキー、{@link GenDialect.ColumnType}を値とするマップ */ - @SuppressWarnings("unchecked") - protected Map<Object, ColumnType> columnTypeMap = new CaseInsensitiveMap(); - - /** カラムのSQL型をキー、{@link GenDialect.ColumnType}を値とするマップ。 */ - protected Map<Integer, ColumnType> fallbackColumnTypeMap = new HashMap<Integer, ColumnType>(); - - - /** - * インスタンスを構築する。 - */ - public StandardGenDialect() { - sqlTypeMap.put(Types.BIGINT, new SqlType("bigint")); - sqlTypeMap.put(Types.BINARY, new SqlType("binary")); - sqlTypeMap.put(Types.BLOB, new SqlType("blob")); - sqlTypeMap.put(Types.BOOLEAN, new SqlType("boolean")); - sqlTypeMap.put(Types.CHAR, new SqlType("char")); - sqlTypeMap.put(Types.CLOB, new SqlType("clob")); - sqlTypeMap.put(Types.DATE, new SqlType("clob")); - sqlTypeMap.put(Types.DECIMAL, new SqlType("decimal")); - sqlTypeMap.put(Types.DOUBLE, new SqlType("double")); - sqlTypeMap.put(Types.FLOAT, new SqlType("float")); - sqlTypeMap.put(Types.INTEGER, new SqlType("integer")); - sqlTypeMap.put(Types.SMALLINT, new SqlType("smallint")); - sqlTypeMap.put(Types.TIME, new SqlType("time")); - sqlTypeMap.put(Types.TIMESTAMP, new SqlType("timestamp")); - sqlTypeMap.put(Types.VARCHAR, new SqlType("varchar")); - - columnTypeMap.put("bigint", StandardColumnType.BIGINT); - columnTypeMap.put("binary", StandardColumnType.BINARY); - columnTypeMap.put("bit", StandardColumnType.BIT); - columnTypeMap.put("blob", StandardColumnType.BLOB); - columnTypeMap.put("boolean", StandardColumnType.BOOLEAN); - columnTypeMap.put("char", StandardColumnType.CHAR); - columnTypeMap.put("clob", StandardColumnType.CLOB); - columnTypeMap.put("date", StandardColumnType.DATE); - columnTypeMap.put("decimal", StandardColumnType.DECIMAL); - columnTypeMap.put("double", StandardColumnType.DOUBLE); - columnTypeMap.put("float", StandardColumnType.FLOAT); - columnTypeMap.put("integer", StandardColumnType.INTEGER); - columnTypeMap.put("longvarbinary", StandardColumnType.LONGVARBINARY); - columnTypeMap.put("longvarchar", StandardColumnType.LONGVARCHAR); - columnTypeMap.put("numeric", StandardColumnType.NUMERIC); - columnTypeMap.put("real", StandardColumnType.REAL); - columnTypeMap.put("smallint", StandardColumnType.SMALLINT); - columnTypeMap.put("time", StandardColumnType.TIME); - columnTypeMap.put("timestamp", StandardColumnType.TIMESTAMP); - columnTypeMap.put("tinyint", StandardColumnType.TINYINT); - columnTypeMap.put("varbinary", StandardColumnType.VARBINARY); - columnTypeMap.put("varchar", StandardColumnType.VARCHAR); - - fallbackColumnTypeMap.put(Types.BIGINT, StandardColumnType.BIGINT); - fallbackColumnTypeMap.put(Types.BINARY, StandardColumnType.BINARY); - fallbackColumnTypeMap.put(Types.BIT, StandardColumnType.BIT); - fallbackColumnTypeMap.put(Types.BLOB, StandardColumnType.BLOB); - fallbackColumnTypeMap.put(Types.BOOLEAN, StandardColumnType.BOOLEAN); - fallbackColumnTypeMap.put(Types.CHAR, StandardColumnType.CHAR); - fallbackColumnTypeMap.put(Types.CLOB, StandardColumnType.CLOB); - fallbackColumnTypeMap.put(Types.DATE, StandardColumnType.DATE); - fallbackColumnTypeMap.put(Types.DECIMAL, StandardColumnType.DECIMAL); - fallbackColumnTypeMap.put(Types.DOUBLE, StandardColumnType.DOUBLE); - fallbackColumnTypeMap.put(Types.FLOAT, StandardColumnType.FLOAT); - fallbackColumnTypeMap.put(Types.INTEGER, StandardColumnType.INTEGER); - fallbackColumnTypeMap.put(Types.LONGVARBINARY, StandardColumnType.LONGVARBINARY); - fallbackColumnTypeMap.put(Types.LONGVARCHAR, StandardColumnType.LONGVARCHAR); - fallbackColumnTypeMap.put(Types.NUMERIC, StandardColumnType.NUMERIC); - fallbackColumnTypeMap.put(Types.REAL, StandardColumnType.REAL); - fallbackColumnTypeMap.put(Types.SMALLINT, StandardColumnType.SMALLINT); - fallbackColumnTypeMap.put(Types.TIME, StandardColumnType.TIME); - fallbackColumnTypeMap.put(Types.TIMESTAMP, StandardColumnType.TIMESTAMP); - fallbackColumnTypeMap.put(Types.TINYINT, StandardColumnType.TINYINT); - fallbackColumnTypeMap.put(Types.VARBINARY, StandardColumnType.VARBINARY); - fallbackColumnTypeMap.put(Types.VARCHAR, StandardColumnType.VARCHAR); - } - -// public SqlBlockContext createSqlBlockContext() { -// return new StandardSqlBlockContext(); -// } - - /** - * 例外チェーンをたどって原因となった{@link SQLException SQL例外}を取得する。 - * <p> - * 例外チェーンにSQL例外が存在しない場合は<code>null</code>を取得する。 - * </p> - * - * @param t 例外 - * @return 原因となった{@link SQLException SQL例外} - */ -// protected SQLException getCauseSQLException(Throwable t) { -// SQLException cause = null; -// while (t != null) { -// if (t instanceof SQLException) { -// cause = SQLException.class.cast(t); -// if (cause.getNextException() != null) { -// cause = cause.getNextException(); -// t = cause; -// continue; -// } -// } -// t = t.getCause(); -// } -// return cause; -// } -// public String getCloseQuote() { -// return "\""; -// } -// public Map<String, String> getColumnCommentMap(Connection connection, String catalogName, String schemaName, -// String tableName) throws SQLException { -// throw new UnsupportedOperationException("getColumnCommentMap"); -// } - public ColumnType getColumnType(String typeName, int sqlType) { - ColumnType columnType = columnTypeMap.get(typeName); - return columnType != null ? columnType : fallbackColumnTypeMap.get(sqlType); - } - - public GenerationType getDefaultGenerationType() { - return GenerationType.TABLE; - } - - public String getName() { - return null; - } - - // public String getDefaultSchemaName(String userName) { -// return userName; -// } -// -// public String getDropForeignKeySyntax() { -// return "drop constraint"; -// } -// -// public String getDropUniqueKeySyntax() { -// return "drop constraint"; -// } -// - /** - * 例外チェーンをたどって原因となった{@link SQLException#getErrorCode() ベンダー固有の例外コード}を取得する。 - * <p> - * 例外チェーンに{@link SQLException SQL例外}が存在しない場合や、例外コードが設定されていない場合は - * <code>null</code>を取得する。 - * </p> - * - * @param t 例外 - * @return 原因となった{@link SQLException#getErrorCode() ベンダー固有の例外コード} - */ -// protected Integer getErrorCode(Throwable t) { -// SQLException cause = getCauseSQLException(t); -// if (cause != null) { -// return cause.getErrorCode(); -// } -// return null; -// } -// public String getIdentityColumnDefinition() { -// throw new UnsupportedOperationException("getIdentityDefinition"); -// } -// -// public String getIdentityInsertDisableStatement(String tableName) { -// throw new UnsupportedOperationException("getIdentityInsertOffStatement"); -// } -// -// public String getIdentityInsertEnableStatement(String tableName) { -// throw new UnsupportedOperationException("getIdentityInsertOnStatement"); -// } -// -// public String getName() { -// return null; -// } -// -// public String getOpenQuote() { -// return "\""; -// } -// -// public String getSequenceDefinitionFragment(String dataType, long initialValue, int allocationSize) { -// throw new UnsupportedOperationException("getSequenceDefinitionFragment"); -// } -// -// public String getSequenceNextValString(final String sequenceName, final int allocationSize) { -// throw new UnsupportedOperationException("getSequenceNextValString"); -// } -// -// public String getSqlBlockDelimiter() { -// return null; -// } - /** - * 例外チェーンをたどって原因となった{@link SQLException#getSQLState() SQLステート}を取得する。 - * <p> - * 例外チェーンに{@link SQLException SQL例外}が存在しない場合や、SQLステートが設定されていない場合は - * <code>null</code>を取得する。 - * </p> - * - * @param t 例外 - * @return 原因となった{@link SQLException#getSQLState() SQLステート} - */ -// protected String getSQLState(Throwable t) { -// SQLException cause = getCauseSQLException(t); -// if (cause != null && !StringUtil.isEmpty(cause.getSQLState())) { -// return cause.getSQLState(); -// } -// return null; -// } -// -// public SqlType getSqlType(int sqlType) throws UnsupportedSqlTypeException { -// return getSqlTypeInternal(sqlType); -// } - /** - * 内部的にSQL型を取得する。 - * - * @param sqlType JDBCのSQL型 - * @return SQL型 - * @throws UnsupportedSqlTypeException - */ -// protected SqlType getSqlTypeInternal(int sqlType) throws UnsupportedSqlTypeException { -// SqlType type = sqlTypeMap.get(sqlType); -// if (type != null) { -// return type; -// } -// throw new UnsupportedSqlTypeException(sqlType); -// } -// @SuppressWarnings("unused") -// public String getTableComment(Connection connection, String catalogName, String schemaName, String tableName) -// throws SQLException { -// throw new UnsupportedOperationException("getTableComment"); -// } -// -// @SuppressWarnings("unused") -// public boolean isAutoIncrement(Connection connection, String catalogName, String schemaName, String tableName, -// String columnName) throws SQLException { -// return true; -// } -// -// public boolean isColumnNotFound(Throwable throwable) { -// return false; -// } -// -// public boolean isJdbcCommentAvailable() { -// return true; -// } -// -// public boolean isSequenceNotFound(Throwable throwable) { -// return false; -// } -// -// public boolean isTableNotFound(Throwable throwable) { -// return false; -// } -// -// public String quote(String value) { -// if (value == null) { -// return null; -// } -// return getOpenQuote() + value + getCloseQuote(); -// } -// -// public boolean supportsCommentInCreateTable() { -// return false; -// } -// -// public boolean supportsCommentOn() { -// return false; -// } -// -// public boolean supportsGetIndexInfo(String catalogName, String schemaName, String tableName) { -// return true; -// } - public boolean supportsIdentity() { - return false; - } - -// public boolean supportsIdentityInsert() { -// return false; -// } -// -// public boolean supportsIdentityInsertControlStatement() { -// return false; -// } -// -// public boolean supportsNullableUnique() { -// return true; -// } -// -// public boolean supportsReferentialDeleteRule() { -// return true; -// } -// -// public boolean supportsReferentialUpdateRule() { -// return true; -// } -// -// public boolean supportsSequence() { -// return false; -// } -// -// public String unquote(String value) { -// String s = StringUtil.ltrim(value, getOpenQuote()); -// return StringUtil.rtrim(s, getCloseQuote()); -// } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.dialect; + +import java.math.BigDecimal; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.sql.Types; +import java.util.HashMap; +import java.util.Map; + +import javax.persistence.GenerationType; + +import org.jiemamy.entity.io.utils.CaseInsensitiveMap; +import org.jiemamy.entity.io.utils.ColumnUtil; + +/** + * 標準的な方言をあつかうクラスです。 + * + * @author j5ik2o + */ +public class StandardGenDialect implements GenDialect { + + /** + * 標準の{@link ColumnType}の実装クラスです。 + * + * @author j5ik2o + */ + public static class StandardColumnType implements ColumnType { + + private static final StandardColumnType BIGINT = new StandardColumnType("bigint", Long.class); + + private static final StandardColumnType BINARY = new StandardColumnType("binary", byte[].class); + + private static final StandardColumnType BIT = new StandardColumnType("bit", Boolean.class); + + private static final StandardColumnType BLOB = new StandardColumnType("blob", byte[].class, true); + + private static final StandardColumnType BOOLEAN = new StandardColumnType("boolean", Boolean.class); + + private static final StandardColumnType CHAR = new StandardColumnType("char($l)", String.class); + + private static final StandardColumnType CLOB = new StandardColumnType("clob", String.class, true); + + private static final StandardColumnType DATE = new StandardColumnType("date", java.sql.Date.class); + + private static final StandardColumnType DECIMAL = new StandardColumnType("decimal", BigDecimal.class); + + private static final StandardColumnType DOUBLE = new StandardColumnType("double", Double.class); + + private static final StandardColumnType FLOAT = new StandardColumnType("float", Float.class); + + private static final StandardColumnType INTEGER = new StandardColumnType("integer", Integer.class); + + private static final StandardColumnType LONGVARBINARY = new StandardColumnType("longvarbinary", byte[].class); + + private static final StandardColumnType LONGVARCHAR = new StandardColumnType("longvarchar", String.class); + + private static final StandardColumnType NUMERIC = new StandardColumnType("numeric", BigDecimal.class); + + private static final StandardColumnType REAL = new StandardColumnType("real", Float.class); + + private static final StandardColumnType SMALLINT = new StandardColumnType("smallint", Short.class); + + private static final StandardColumnType TIME = new StandardColumnType("time", java.sql.Time.class); + + private static final StandardColumnType TIMESTAMP = new StandardColumnType("timestamp", Timestamp.class); + + private static final StandardColumnType TINYINT = new StandardColumnType("tinyint", Short.class); + + private static final StandardColumnType VARBINARY = new StandardColumnType("varbinary($l)", byte[].class); + + private static final StandardColumnType VARCHAR = new StandardColumnType("varchar($l)", String.class); + + /** カラム定義 */ + protected String dataType; + + /** 属性のクラス */ + protected Class<?> attributeClass; + + /** LOBの場合{@code true} */ + protected boolean lob; + + + /** + * インスタンスを構築する。 + * + * @param dataType データ型 + * @param attributeClass 属性のクラス + */ + protected StandardColumnType(String dataType, Class<?> attributeClass) { + this(dataType, attributeClass, false); + } + + /** + * インスタンスを構築する。 + * + * @param dataType カラム定義 + * @param attributeClass 属性のクラス + * @param lob LOBの場合{@code true} + */ + protected StandardColumnType(String dataType, Class<?> attributeClass, boolean lob) { + this.dataType = dataType; + this.attributeClass = attributeClass; + this.lob = lob; + } + + public Class<?> getAttributeClass(int length, int precision, int scale) { + return attributeClass; + } + + public String getColumnDefinition(int length, int precision, int scale, String defaultValue) { + String completeDataType = ColumnUtil.formatDataType(dataType, length, precision, scale); + return getColumnDefinitionInternal(completeDataType, defaultValue); + } + + /** + * カラム定義を取得する。 + * + * @param completeDataType 完全なデータ型 + * @param defaultValue デフォルト値、存在しない場合は{@code null} + * @return カラム定義 + */ + protected String getColumnDefinitionInternal(String completeDataType, String defaultValue) { + if (defaultValue == null) { + return completeDataType; + } + return completeDataType + " default " + defaultValue; + } + + public boolean isLob() { + return lob; + } + + } + + + /** + * 標準の{@link StandardColumnType}の実装クラスです。 + * + * @author j5ik2o + */ +// public static class StandardSqlBlockContext implements SqlBlockContext { +// +// /** SQLブロックの開始を表すキーワードの連なりのリスト */ +// protected List<List<String>> sqlBlockStartKeywordsList = new ArrayList<List<String>>(); +// +// /** 追加されたキーワードの連なり */ +// protected List<String> keywords = new ArrayList<String>(); +// +// /** SQLブロックの内側の場合{@code true} */ +// protected boolean inSqlBlock; +// +// +// public void addKeyword(String keyword) { +// if (!inSqlBlock) { +// keywords.add(keyword); +// check(); +// } +// } +// +// /** +// * ブロックの内側かどうかチェックする。 +// */ +// protected void check() { +// for (List<String> startKeywords : sqlBlockStartKeywordsList) { +// if (startKeywords.size() > keywords.size()) { +// continue; +// } +// for (int i = 0; i < startKeywords.size(); i++) { +// String word1 = startKeywords.get(i); +// String word2 = keywords.get(i); +// inSqlBlock = word1.equalsIgnoreCase(word2); +// if (!inSqlBlock) { +// break; +// } +// } +// if (inSqlBlock) { +// break; +// } +// } +// } +// +// public boolean isInSqlBlock() { +// return inSqlBlock; +// } +// } + /** SQL型をキー、{@link SqlType}を値とするマップ */ + protected Map<Integer, SqlType> sqlTypeMap = new HashMap<Integer, SqlType>(); + + /** カラムの型名をキー、{@link GenDialect.ColumnType}を値とするマップ */ + @SuppressWarnings("unchecked") + protected Map<Object, ColumnType> columnTypeMap = new CaseInsensitiveMap(); + + /** カラムのSQL型をキー、{@link GenDialect.ColumnType}を値とするマップ。 */ + protected Map<Integer, ColumnType> fallbackColumnTypeMap = new HashMap<Integer, ColumnType>(); + + + /** + * インスタンスを構築する。 + */ + public StandardGenDialect() { + sqlTypeMap.put(Types.BIGINT, new SqlType("bigint")); + sqlTypeMap.put(Types.BINARY, new SqlType("binary")); + sqlTypeMap.put(Types.BLOB, new SqlType("blob")); + sqlTypeMap.put(Types.BOOLEAN, new SqlType("boolean")); + sqlTypeMap.put(Types.CHAR, new SqlType("char")); + sqlTypeMap.put(Types.CLOB, new SqlType("clob")); + sqlTypeMap.put(Types.DATE, new SqlType("clob")); + sqlTypeMap.put(Types.DECIMAL, new SqlType("decimal")); + sqlTypeMap.put(Types.DOUBLE, new SqlType("double")); + sqlTypeMap.put(Types.FLOAT, new SqlType("float")); + sqlTypeMap.put(Types.INTEGER, new SqlType("integer")); + sqlTypeMap.put(Types.SMALLINT, new SqlType("smallint")); + sqlTypeMap.put(Types.TIME, new SqlType("time")); + sqlTypeMap.put(Types.TIMESTAMP, new SqlType("timestamp")); + sqlTypeMap.put(Types.VARCHAR, new SqlType("varchar")); + + columnTypeMap.put("bigint", StandardColumnType.BIGINT); + columnTypeMap.put("binary", StandardColumnType.BINARY); + columnTypeMap.put("bit", StandardColumnType.BIT); + columnTypeMap.put("blob", StandardColumnType.BLOB); + columnTypeMap.put("boolean", StandardColumnType.BOOLEAN); + columnTypeMap.put("char", StandardColumnType.CHAR); + columnTypeMap.put("clob", StandardColumnType.CLOB); + columnTypeMap.put("date", StandardColumnType.DATE); + columnTypeMap.put("decimal", StandardColumnType.DECIMAL); + columnTypeMap.put("double", StandardColumnType.DOUBLE); + columnTypeMap.put("float", StandardColumnType.FLOAT); + columnTypeMap.put("integer", StandardColumnType.INTEGER); + columnTypeMap.put("longvarbinary", StandardColumnType.LONGVARBINARY); + columnTypeMap.put("longvarchar", StandardColumnType.LONGVARCHAR); + columnTypeMap.put("numeric", StandardColumnType.NUMERIC); + columnTypeMap.put("real", StandardColumnType.REAL); + columnTypeMap.put("smallint", StandardColumnType.SMALLINT); + columnTypeMap.put("time", StandardColumnType.TIME); + columnTypeMap.put("timestamp", StandardColumnType.TIMESTAMP); + columnTypeMap.put("tinyint", StandardColumnType.TINYINT); + columnTypeMap.put("varbinary", StandardColumnType.VARBINARY); + columnTypeMap.put("varchar", StandardColumnType.VARCHAR); + + fallbackColumnTypeMap.put(Types.BIGINT, StandardColumnType.BIGINT); + fallbackColumnTypeMap.put(Types.BINARY, StandardColumnType.BINARY); + fallbackColumnTypeMap.put(Types.BIT, StandardColumnType.BIT); + fallbackColumnTypeMap.put(Types.BLOB, StandardColumnType.BLOB); + fallbackColumnTypeMap.put(Types.BOOLEAN, StandardColumnType.BOOLEAN); + fallbackColumnTypeMap.put(Types.CHAR, StandardColumnType.CHAR); + fallbackColumnTypeMap.put(Types.CLOB, StandardColumnType.CLOB); + fallbackColumnTypeMap.put(Types.DATE, StandardColumnType.DATE); + fallbackColumnTypeMap.put(Types.DECIMAL, StandardColumnType.DECIMAL); + fallbackColumnTypeMap.put(Types.DOUBLE, StandardColumnType.DOUBLE); + fallbackColumnTypeMap.put(Types.FLOAT, StandardColumnType.FLOAT); + fallbackColumnTypeMap.put(Types.INTEGER, StandardColumnType.INTEGER); + fallbackColumnTypeMap.put(Types.LONGVARBINARY, StandardColumnType.LONGVARBINARY); + fallbackColumnTypeMap.put(Types.LONGVARCHAR, StandardColumnType.LONGVARCHAR); + fallbackColumnTypeMap.put(Types.NUMERIC, StandardColumnType.NUMERIC); + fallbackColumnTypeMap.put(Types.REAL, StandardColumnType.REAL); + fallbackColumnTypeMap.put(Types.SMALLINT, StandardColumnType.SMALLINT); + fallbackColumnTypeMap.put(Types.TIME, StandardColumnType.TIME); + fallbackColumnTypeMap.put(Types.TIMESTAMP, StandardColumnType.TIMESTAMP); + fallbackColumnTypeMap.put(Types.TINYINT, StandardColumnType.TINYINT); + fallbackColumnTypeMap.put(Types.VARBINARY, StandardColumnType.VARBINARY); + fallbackColumnTypeMap.put(Types.VARCHAR, StandardColumnType.VARCHAR); + } + +// public SqlBlockContext createSqlBlockContext() { +// return new StandardSqlBlockContext(); +// } + + /** + * 例外チェーンをたどって原因となった{@link SQLException SQL例外}を取得する。 + * <p> + * 例外チェーンにSQL例外が存在しない場合は<code>null</code>を取得する。 + * </p> + * + * @param t 例外 + * @return 原因となった{@link SQLException SQL例外} + */ +// protected SQLException getCauseSQLException(Throwable t) { +// SQLException cause = null; +// while (t != null) { +// if (t instanceof SQLException) { +// cause = SQLException.class.cast(t); +// if (cause.getNextException() != null) { +// cause = cause.getNextException(); +// t = cause; +// continue; +// } +// } +// t = t.getCause(); +// } +// return cause; +// } +// public String getCloseQuote() { +// return "\""; +// } +// public Map<String, String> getColumnCommentMap(Connection connection, String catalogName, String schemaName, +// String tableName) throws SQLException { +// throw new UnsupportedOperationException("getColumnCommentMap"); +// } + public ColumnType getColumnType(String typeName, int sqlType) { + ColumnType columnType = columnTypeMap.get(typeName); + return columnType != null ? columnType : fallbackColumnTypeMap.get(sqlType); + } + + public GenerationType getDefaultGenerationType() { + return GenerationType.TABLE; + } + + public String getName() { + return null; + } + + // public String getDefaultSchemaName(String userName) { +// return userName; +// } +// +// public String getDropForeignKeySyntax() { +// return "drop constraint"; +// } +// +// public String getDropUniqueKeySyntax() { +// return "drop constraint"; +// } +// + /** + * 例外チェーンをたどって原因となった{@link SQLException#getErrorCode() ベンダー固有の例外コード}を取得する。 + * <p> + * 例外チェーンに{@link SQLException SQL例外}が存在しない場合や、例外コードが設定されていない場合は + * <code>null</code>を取得する。 + * </p> + * + * @param t 例外 + * @return 原因となった{@link SQLException#getErrorCode() ベンダー固有の例外コード} + */ +// protected Integer getErrorCode(Throwable t) { +// SQLException cause = getCauseSQLException(t); +// if (cause != null) { +// return cause.getErrorCode(); +// } +// return null; +// } +// public String getIdentityColumnDefinition() { +// throw new UnsupportedOperationException("getIdentityDefinition"); +// } +// +// public String getIdentityInsertDisableStatement(String tableName) { +// throw new UnsupportedOperationException("getIdentityInsertOffStatement"); +// } +// +// public String getIdentityInsertEnableStatement(String tableName) { +// throw new UnsupportedOperationException("getIdentityInsertOnStatement"); +// } +// +// public String getName() { +// return null; +// } +// +// public String getOpenQuote() { +// return "\""; +// } +// +// public String getSequenceDefinitionFragment(String dataType, long initialValue, int allocationSize) { +// throw new UnsupportedOperationException("getSequenceDefinitionFragment"); +// } +// +// public String getSequenceNextValString(final String sequenceName, final int allocationSize) { +// throw new UnsupportedOperationException("getSequenceNextValString"); +// } +// +// public String getSqlBlockDelimiter() { +// return null; +// } + /** + * 例外チェーンをたどって原因となった{@link SQLException#getSQLState() SQLステート}を取得する。 + * <p> + * 例外チェーンに{@link SQLException SQL例外}が存在しない場合や、SQLステートが設定されていない場合は + * <code>null</code>を取得する。 + * </p> + * + * @param t 例外 + * @return 原因となった{@link SQLException#getSQLState() SQLステート} + */ +// protected String getSQLState(Throwable t) { +// SQLException cause = getCauseSQLException(t); +// if (cause != null && !StringUtil.isEmpty(cause.getSQLState())) { +// return cause.getSQLState(); +// } +// return null; +// } +// +// public SqlType getSqlType(int sqlType) throws UnsupportedSqlTypeException { +// return getSqlTypeInternal(sqlType); +// } + /** + * 内部的にSQL型を取得する。 + * + * @param sqlType JDBCのSQL型 + * @return SQL型 + * @throws UnsupportedSqlTypeException + */ +// protected SqlType getSqlTypeInternal(int sqlType) throws UnsupportedSqlTypeException { +// SqlType type = sqlTypeMap.get(sqlType); +// if (type != null) { +// return type; +// } +// throw new UnsupportedSqlTypeException(sqlType); +// } +// @SuppressWarnings("unused") +// public String getTableComment(Connection connection, String catalogName, String schemaName, String tableName) +// throws SQLException { +// throw new UnsupportedOperationException("getTableComment"); +// } +// +// @SuppressWarnings("unused") +// public boolean isAutoIncrement(Connection connection, String catalogName, String schemaName, String tableName, +// String columnName) throws SQLException { +// return true; +// } +// +// public boolean isColumnNotFound(Throwable throwable) { +// return false; +// } +// +// public boolean isJdbcCommentAvailable() { +// return true; +// } +// +// public boolean isSequenceNotFound(Throwable throwable) { +// return false; +// } +// +// public boolean isTableNotFound(Throwable throwable) { +// return false; +// } +// +// public String quote(String value) { +// if (value == null) { +// return null; +// } +// return getOpenQuote() + value + getCloseQuote(); +// } +// +// public boolean supportsCommentInCreateTable() { +// return false; +// } +// +// public boolean supportsCommentOn() { +// return false; +// } +// +// public boolean supportsGetIndexInfo(String catalogName, String schemaName, String tableName) { +// return true; +// } + public boolean supportsIdentity() { + return false; + } + +// public boolean supportsIdentityInsert() { +// return false; +// } +// +// public boolean supportsIdentityInsertControlStatement() { +// return false; +// } +// +// public boolean supportsNullableUnique() { +// return true; +// } +// +// public boolean supportsReferentialDeleteRule() { +// return true; +// } +// +// public boolean supportsReferentialUpdateRule() { +// return true; +// } +// +// public boolean supportsSequence() { +// return false; +// } +// +// public String unquote(String value) { +// String s = StringUtil.ltrim(value, getOpenQuote()); +// return StringUtil.rtrim(s, getCloseQuote()); +// } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/dialect/StandardGenDialect.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/GenerateException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/GenerateException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/GenerateException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,65 +1,65 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.generator; - -/** - * 生成に失敗した場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class GenerateException extends Exception { - - /** - * インスタンスを生成する。 - * - */ - public GenerateException() { - super(); - } - - /** - * インスタンスを生成する。 - * - * @param message メッセージ - */ - public GenerateException(String message) { - super(message); - } - - /** - * インスタンスを生成する。 - * - * @param message メッセージ - * @param cause 原因 - */ - public GenerateException(String message, Throwable cause) { - super(message, cause); - } - - /** - * インスタンスを生成する。 - * - * @param cause 原因 - */ - public GenerateException(Throwable cause) { - super(cause); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.generator; + +/** + * 生成に失敗した場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class GenerateException extends Exception { + + /** + * インスタンスを生成する。 + * + */ + public GenerateException() { + super(); + } + + /** + * インスタンスを生成する。 + * + * @param message メッセージ + */ + public GenerateException(String message) { + super(message); + } + + /** + * インスタンスを生成する。 + * + * @param message メッセージ + * @param cause 原因 + */ + public GenerateException(String message, Throwable cause) { + super(message, cause); + } + + /** + * インスタンスを生成する。 + * + * @param cause 原因 + */ + public GenerateException(Throwable cause) { + super(cause); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/GenerateException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/Generator.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/Generator.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/Generator.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,36 +1,36 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.generator; - -/** - * ファイルを生成するインタフェース。 - * - * @author j5ik2o - */ -public interface Generator { - - /** - * ファイルを生成する。 - * - * @param context コンテキスト - * @throws GenerateException 入出力が失敗した場合 - */ - void generate(GeneratorContext context) throws GenerateException; - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.generator; + +/** + * ファイルを生成するインタフェース。 + * + * @author j5ik2o + */ +public interface Generator { + + /** + * ファイルを生成する。 + * + * @param context コンテキスト + * @throws GenerateException 入出力が失敗した場合 + */ + void generate(GeneratorContext context) throws GenerateException; + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/Generator.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/GeneratorContext.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/GeneratorContext.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/GeneratorContext.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,64 +1,64 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.generator; - -import java.io.File; - -/** - * {@link Generator}のためのコンテキストインターフェイス。 - * - * @author j5ik2o - */ -public interface GeneratorContext { - - /** - * エンコーディングを取得する。 - * - * @return エンコーディング - */ - String getEncoding(); - - /** - * 生成するファイルを取得する。 - * - * @return 生成するファイル - */ - File getFile(); - - /** - * データモデルを取得する。 - * - * @return データモデル - */ - Object getModel(); - - /** - * テンプレート名を取得する。 - * - * @return テンプレート名 - */ - String getTemplateName(); - - /** - * 上書きフラグを取得する。 - * - * @return 上書きする場合は{@code true}、しない場合は{@code false} - */ - boolean isOverwrite(); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.generator; + +import java.io.File; + +/** + * {@link Generator}のためのコンテキストインターフェイス。 + * + * @author j5ik2o + */ +public interface GeneratorContext { + + /** + * エンコーディングを取得する。 + * + * @return エンコーディング + */ + String getEncoding(); + + /** + * 生成するファイルを取得する。 + * + * @return 生成するファイル + */ + File getFile(); + + /** + * データモデルを取得する。 + * + * @return データモデル + */ + Object getModel(); + + /** + * テンプレート名を取得する。 + * + * @return テンプレート名 + */ + String getTemplateName(); + + /** + * 上書きフラグを取得する。 + * + * @return 上書きする場合は{@code true}、しない場合は{@code false} + */ + boolean isOverwrite(); +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/GeneratorContext.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/DeleteEmptyFileWriter.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/DeleteEmptyFileWriter.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/DeleteEmptyFileWriter.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,118 +1,118 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.generator.impl; - -import java.io.File; -import java.io.FilterWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.Writer; - -import org.jiemamy.utils.FileInputStreamUtil; - -/** - * 空のファイルを削除する{@link Writer}の実装。 - * - * @author j5ik2o - */ -public class DeleteEmptyFileWriter extends FilterWriter { - - /** 書き込みが行われた場合{@code true} */ - protected boolean written; - - /** 削除された場合{@code true} */ - protected boolean deleted; - - /** 書き込み先のファイル */ - protected File file; - - - /** - * インスタンスを生成する。 - * - * @param writer ライタ - * @param file 書き込み先のファイル - */ - public DeleteEmptyFileWriter(Writer writer, File file) { - super(writer); - if (file == null) { - throw new NullPointerException("file"); - } - this.file = file; - } - - @Override - public void close() throws IOException { - super.close(); - if (!written && file.exists() && isEmpty()) { - deleted = file.delete(); - } - } - - /** - * ファイルが削除された場合のフラグを取得する。 - * - * @return 削除された場合{@code true}、そうでない場合{@code false} - */ - public boolean isDeleted() { - return deleted; - } - - /** - * ファイルが空の場合のフラグを取得する。 - * - * @return ファイルが空の場合は{@code true}、そうでない場合{@code false} - * @throws IOException 入出力が失敗した場合 - */ - protected boolean isEmpty() throws IOException { - InputStream is = FileInputStreamUtil.create(file); - try { - return is.read() == -1; - } finally { - if (is != null) { - is.close(); - } - } - } - - @Override - public void write(char[] cbuf, int off, int len) throws IOException { - if (len <= 0) { - return; - } - written = true; - super.write(cbuf, off, len); - } - - @Override - public void write(int c) throws IOException { - written = true; - super.write(c); - } - - @Override - public void write(String str, int off, int len) throws IOException { - if (len <= 0) { - return; - } - written = true; - super.write(str, off, len); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.generator.impl; + +import java.io.File; +import java.io.FilterWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.Writer; + +import org.jiemamy.utils.FileInputStreamUtil; + +/** + * 空のファイルを削除する{@link Writer}の実装。 + * + * @author j5ik2o + */ +public class DeleteEmptyFileWriter extends FilterWriter { + + /** 書き込みが行われた場合{@code true} */ + protected boolean written; + + /** 削除された場合{@code true} */ + protected boolean deleted; + + /** 書き込み先のファイル */ + protected File file; + + + /** + * インスタンスを生成する。 + * + * @param writer ライタ + * @param file 書き込み先のファイル + */ + public DeleteEmptyFileWriter(Writer writer, File file) { + super(writer); + if (file == null) { + throw new NullPointerException("file"); + } + this.file = file; + } + + @Override + public void close() throws IOException { + super.close(); + if (!written && file.exists() && isEmpty()) { + deleted = file.delete(); + } + } + + /** + * ファイルが削除された場合のフラグを取得する。 + * + * @return 削除された場合{@code true}、そうでない場合{@code false} + */ + public boolean isDeleted() { + return deleted; + } + + /** + * ファイルが空の場合のフラグを取得する。 + * + * @return ファイルが空の場合は{@code true}、そうでない場合{@code false} + * @throws IOException 入出力が失敗した場合 + */ + protected boolean isEmpty() throws IOException { + InputStream is = FileInputStreamUtil.create(file); + try { + return is.read() == -1; + } finally { + if (is != null) { + is.close(); + } + } + } + + @Override + public void write(char[] cbuf, int off, int len) throws IOException { + if (len <= 0) { + return; + } + written = true; + super.write(cbuf, off, len); + } + + @Override + public void write(int c) throws IOException { + written = true; + super.write(c); + } + + @Override + public void write(String str, int off, int len) throws IOException { + if (len <= 0) { + return; + } + written = true; + super.write(str, off, len); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/DeleteEmptyFileWriter.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/GeneratorContextImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/GeneratorContextImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/GeneratorContextImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,109 +1,109 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.generator.impl; - -import java.io.File; - -import org.jiemamy.entity.io.gen.generator.GeneratorContext; - - -/** - * {@link GeneratorContext}の実装クラス。 - * - * @author j5ik2o - */ -public class GeneratorContextImpl implements GeneratorContext { - - private String encoding; - - private File file; - - private Object model; - - private String templateName; - - private boolean overwrite; - - - public String getEncoding() { - return encoding; - } - - public File getFile() { - return file; - } - - public Object getModel() { - return model; - } - - public String getTemplateName() { - return templateName; - } - - public boolean isOverwrite() { - return overwrite; - } - - /** - * エンコーディングを設定する。 - * - * @param encoding エンコーディング - */ - public void setEncoding(String encoding) { - this.encoding = encoding; - } - - /** - * 生成するファイルを設定する。 - * - * @param file 生成するファイル - */ - public void setFile(File file) { - this.file = file; - } - - /** - * データモデルを設定する。 - * - * @param model データモデル - */ - public void setModel(Object model) { - this.model = model; - } - - /** - * 上書きフラグを設定する。 - * - * @param overwrite 上書きフラグ - */ - public void setOverwrite(boolean overwrite) { - this.overwrite = overwrite; - } - - /** - * テンプレート名を設定する。 - * - * @param templateName テンプレート名 - */ - public void setTemplateName(String templateName) { - this.templateName = templateName; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.generator.impl; + +import java.io.File; + +import org.jiemamy.entity.io.gen.generator.GeneratorContext; + + +/** + * {@link GeneratorContext}の実装クラス。 + * + * @author j5ik2o + */ +public class GeneratorContextImpl implements GeneratorContext { + + private String encoding; + + private File file; + + private Object model; + + private String templateName; + + private boolean overwrite; + + + public String getEncoding() { + return encoding; + } + + public File getFile() { + return file; + } + + public Object getModel() { + return model; + } + + public String getTemplateName() { + return templateName; + } + + public boolean isOverwrite() { + return overwrite; + } + + /** + * エンコーディングを設定する。 + * + * @param encoding エンコーディング + */ + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + /** + * 生成するファイルを設定する。 + * + * @param file 生成するファイル + */ + public void setFile(File file) { + this.file = file; + } + + /** + * データモデルを設定する。 + * + * @param model データモデル + */ + public void setModel(Object model) { + this.model = model; + } + + /** + * 上書きフラグを設定する。 + * + * @param overwrite 上書きフラグ + */ + public void setOverwrite(boolean overwrite) { + this.overwrite = overwrite; + } + + /** + * テンプレート名を設定する。 + * + * @param templateName テンプレート名 + */ + public void setTemplateName(String templateName) { + this.templateName = templateName; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/GeneratorContextImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/GeneratorImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/GeneratorImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/GeneratorImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,221 +1,221 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.generator.impl; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.nio.charset.Charset; -import java.util.Locale; - -import freemarker.cache.FileTemplateLoader; -import freemarker.cache.MultiTemplateLoader; -import freemarker.cache.TemplateLoader; -import freemarker.template.Configuration; -import freemarker.template.DefaultObjectWrapper; -import freemarker.template.Template; -import freemarker.template.TemplateException; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.entity.io.gen.generator.GenerateException; -import org.jiemamy.entity.io.gen.generator.Generator; -import org.jiemamy.entity.io.gen.generator.GeneratorContext; -import org.jiemamy.utils.FileOutputStreamUtil; - -/** - * エンティティを生成するためのジェネレータクラス。 - * - * @author j5ik2o - */ -public class GeneratorImpl implements Generator { - - private Configuration configuration; - - /** デフォルトのテンプレートディレクトリの名前 */ - protected static final String DEFAULT_TEMPLATE_DIR_NAME = "org/jiemamy/entity/io/templates"; - - - /** - * インスタンスを生成する。 - * - * @param configuration FreeMarkerの設定 - */ - public GeneratorImpl(Configuration configuration) { - Validate.notNull(configuration); - this.configuration = configuration; - } - - /** - * インスタンスを生成する。 - * - * @param templateFileEncoding テンプレートファイルのエンコーディング - * @param templateFilePrimaryDir テンプレートファイルを格納したプライマリディレクトリ、プライマリディレクトリを使用しない場合{@code null} - * @throws IOException 入出力が失敗した場合 - */ - public GeneratorImpl(String templateFileEncoding, File templateFilePrimaryDir) throws IOException { - Validate.notNull(templateFileEncoding); - configuration = new Configuration(); - configuration.setObjectWrapper(new DefaultObjectWrapper()); - configuration.setSharedVariable("include", new IncludeDirective()); - configuration.setSharedVariable("currentDate", new OnDemandDateModel()); - configuration.setEncoding(Locale.getDefault(), templateFileEncoding); - configuration.setNumberFormat("0.#####"); - configuration.setTemplateLoader(createTemplateLoader(templateFilePrimaryDir)); - } - - /** - * {@link TemplateLoader}を作成する。 - * - * @param templateFilePrimaryDir テンプレートファイルを格納したプライマリディレクトリ、プライマリディレクトリを使用しない場合{@code null} - * @return {@link TemplateLoader} - * @throws IOException 入出力が失敗した場合 - */ - protected TemplateLoader createTemplateLoader(File templateFilePrimaryDir) throws IOException { - TemplateLoader primary = null; - if (templateFilePrimaryDir != null) { - primary = new FileTemplateLoader(templateFilePrimaryDir); - } - TemplateLoader secondary = new ResourceTemplateLoader(DEFAULT_TEMPLATE_DIR_NAME); - if (primary == null) { - return secondary; - } - return new MultiTemplateLoader(new TemplateLoader[] { - primary, - secondary - }); - } - - /** - * {@code file}が存在する場合に{@code true}を取得する。 - * - * @param file ファイル - * @return {@code file}が存在する場合は{@code true}、そうでない場合は{@code false} - */ - protected boolean exists(File file) { - Validate.notNull(file); - return file.exists(); - } - - public void generate(GeneratorContext context) throws GenerateException { - Validate.notNull(context); - boolean exists = exists(context.getFile()); - if (!context.isOverwrite() && exists) { - return; - } - File dir = context.getFile().getParentFile(); - if (dir != null) { - mkdirs(dir); - } - Writer writer = null; - try { - writer = openWriter(context); - } catch (FileNotFoundException e) { - throw new GenerateException(e); - } - try { - Template template = getTemplate(context.getTemplateName()); - process(template, context.getModel(), writer); - } catch (TemplateException e) { - e.printStackTrace(); - throw new GenerateException(e); - } catch (IOException e) { - e.printStackTrace(); - throw new GenerateException(e); - } finally { - if (writer != null) { - try { - writer.close(); - } catch (IOException e) { - throw new GenerateException(e); - } - } - } - if (writer instanceof DeleteEmptyFileWriter) { - if (((DeleteEmptyFileWriter) writer).isDeleted()) { - return; - } - } - } - - /** - * テンプレートを取得する。 - * - * @param name テンプレートの名前 - * @return テンプレート - * @throws IOException 入出力が失敗した場合 - */ - protected Template getTemplate(String name) throws IOException { - Validate.notNull(name); - return configuration.getTemplate(name); - } - - /** - * テンプレートを取得する。 - * - * @param name テンプレートの名前 - * @return テンプレート - * @throws IOException 入出力が失敗した場合 - */ - protected Template getTemplate1(String name) throws IOException { - Validate.notNull(name); - return configuration.getTemplate(name); - } - - /** - * ディレクトリを生成する。 - * - * @param dir ディレクトリ - */ - protected void mkdirs(File dir) { - dir.mkdirs(); - } - - /** - * {@link Writer}を開きます。 - * - * @param context コンテキスト - * @return {@link Writer} - * @throws FileNotFoundException ファイルが見つからなかった場合 - */ - protected Writer openWriter(GeneratorContext context) throws FileNotFoundException { - Charset charset = Charset.forName(context.getEncoding()); - FileOutputStream fos = FileOutputStreamUtil.create(context.getFile()); - OutputStreamWriter osw = new OutputStreamWriter(fos, charset); - BufferedWriter bw = new BufferedWriter(osw); - return new DeleteEmptyFileWriter(bw, context.getFile()); - } - - /** - * テンプレートを処理する。 - * - * @param template テンプレート - * @param dataModel データモデル - * @param writer ライタ - * @throws IOException 入出力が失敗した場合 - * @throws TemplateException テンプレートの処理に失敗した場合 - */ - protected void process(Template template, Object dataModel, Writer writer) throws TemplateException, IOException { - template.process(dataModel, writer); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.generator.impl; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.nio.charset.Charset; +import java.util.Locale; + +import freemarker.cache.FileTemplateLoader; +import freemarker.cache.MultiTemplateLoader; +import freemarker.cache.TemplateLoader; +import freemarker.template.Configuration; +import freemarker.template.DefaultObjectWrapper; +import freemarker.template.Template; +import freemarker.template.TemplateException; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.entity.io.gen.generator.GenerateException; +import org.jiemamy.entity.io.gen.generator.Generator; +import org.jiemamy.entity.io.gen.generator.GeneratorContext; +import org.jiemamy.utils.FileOutputStreamUtil; + +/** + * エンティティを生成するためのジェネレータクラス。 + * + * @author j5ik2o + */ +public class GeneratorImpl implements Generator { + + private Configuration configuration; + + /** デフォルトのテンプレートディレクトリの名前 */ + protected static final String DEFAULT_TEMPLATE_DIR_NAME = "org/jiemamy/entity/io/templates"; + + + /** + * インスタンスを生成する。 + * + * @param configuration FreeMarkerの設定 + */ + public GeneratorImpl(Configuration configuration) { + Validate.notNull(configuration); + this.configuration = configuration; + } + + /** + * インスタンスを生成する。 + * + * @param templateFileEncoding テンプレートファイルのエンコーディング + * @param templateFilePrimaryDir テンプレートファイルを格納したプライマリディレクトリ、プライマリディレクトリを使用しない場合{@code null} + * @throws IOException 入出力が失敗した場合 + */ + public GeneratorImpl(String templateFileEncoding, File templateFilePrimaryDir) throws IOException { + Validate.notNull(templateFileEncoding); + configuration = new Configuration(); + configuration.setObjectWrapper(new DefaultObjectWrapper()); + configuration.setSharedVariable("include", new IncludeDirective()); + configuration.setSharedVariable("currentDate", new OnDemandDateModel()); + configuration.setEncoding(Locale.getDefault(), templateFileEncoding); + configuration.setNumberFormat("0.#####"); + configuration.setTemplateLoader(createTemplateLoader(templateFilePrimaryDir)); + } + + /** + * {@link TemplateLoader}を作成する。 + * + * @param templateFilePrimaryDir テンプレートファイルを格納したプライマリディレクトリ、プライマリディレクトリを使用しない場合{@code null} + * @return {@link TemplateLoader} + * @throws IOException 入出力が失敗した場合 + */ + protected TemplateLoader createTemplateLoader(File templateFilePrimaryDir) throws IOException { + TemplateLoader primary = null; + if (templateFilePrimaryDir != null) { + primary = new FileTemplateLoader(templateFilePrimaryDir); + } + TemplateLoader secondary = new ResourceTemplateLoader(DEFAULT_TEMPLATE_DIR_NAME); + if (primary == null) { + return secondary; + } + return new MultiTemplateLoader(new TemplateLoader[] { + primary, + secondary + }); + } + + /** + * {@code file}が存在する場合に{@code true}を取得する。 + * + * @param file ファイル + * @return {@code file}が存在する場合は{@code true}、そうでない場合は{@code false} + */ + protected boolean exists(File file) { + Validate.notNull(file); + return file.exists(); + } + + public void generate(GeneratorContext context) throws GenerateException { + Validate.notNull(context); + boolean exists = exists(context.getFile()); + if (!context.isOverwrite() && exists) { + return; + } + File dir = context.getFile().getParentFile(); + if (dir != null) { + mkdirs(dir); + } + Writer writer = null; + try { + writer = openWriter(context); + } catch (FileNotFoundException e) { + throw new GenerateException(e); + } + try { + Template template = getTemplate(context.getTemplateName()); + process(template, context.getModel(), writer); + } catch (TemplateException e) { + e.printStackTrace(); + throw new GenerateException(e); + } catch (IOException e) { + e.printStackTrace(); + throw new GenerateException(e); + } finally { + if (writer != null) { + try { + writer.close(); + } catch (IOException e) { + throw new GenerateException(e); + } + } + } + if (writer instanceof DeleteEmptyFileWriter) { + if (((DeleteEmptyFileWriter) writer).isDeleted()) { + return; + } + } + } + + /** + * テンプレートを取得する。 + * + * @param name テンプレートの名前 + * @return テンプレート + * @throws IOException 入出力が失敗した場合 + */ + protected Template getTemplate(String name) throws IOException { + Validate.notNull(name); + return configuration.getTemplate(name); + } + + /** + * テンプレートを取得する。 + * + * @param name テンプレートの名前 + * @return テンプレート + * @throws IOException 入出力が失敗した場合 + */ + protected Template getTemplate1(String name) throws IOException { + Validate.notNull(name); + return configuration.getTemplate(name); + } + + /** + * ディレクトリを生成する。 + * + * @param dir ディレクトリ + */ + protected void mkdirs(File dir) { + dir.mkdirs(); + } + + /** + * {@link Writer}を開きます。 + * + * @param context コンテキスト + * @return {@link Writer} + * @throws FileNotFoundException ファイルが見つからなかった場合 + */ + protected Writer openWriter(GeneratorContext context) throws FileNotFoundException { + Charset charset = Charset.forName(context.getEncoding()); + FileOutputStream fos = FileOutputStreamUtil.create(context.getFile()); + OutputStreamWriter osw = new OutputStreamWriter(fos, charset); + BufferedWriter bw = new BufferedWriter(osw); + return new DeleteEmptyFileWriter(bw, context.getFile()); + } + + /** + * テンプレートを処理する。 + * + * @param template テンプレート + * @param dataModel データモデル + * @param writer ライタ + * @throws IOException 入出力が失敗した場合 + * @throws TemplateException テンプレートの処理に失敗した場合 + */ + protected void process(Template template, Object dataModel, Writer writer) throws TemplateException, IOException { + template.process(dataModel, writer); + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/GeneratorImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/IncludeDirective.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/IncludeDirective.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/IncludeDirective.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,68 +1,68 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.generator.impl; - -import java.io.IOException; -import java.util.Map; - -import freemarker.core.Environment; -import freemarker.template.SimpleScalar; -import freemarker.template.Template; -import freemarker.template.TemplateDirectiveBody; -import freemarker.template.TemplateDirectiveModel; -import freemarker.template.TemplateException; -import freemarker.template.TemplateModel; - -/** - * インクルードのディレクティブ。 - * <p> - * インクルード先のテンプレートで任意のオブジェクトをルートのデータモデルに指定できます。 - * </p> - * - * @author j5ik2o - */ -public class IncludeDirective implements TemplateDirectiveModel { - - /** インクルードするテンプレート名のパラメータ名 */ - protected static final String PARAM_NAME = "name"; - - /** ルートモデルのパラメータ名 */ - protected static final String PARAM_ROOT_MODEL = "rootModel"; - - - public void execute(Environment env, @SuppressWarnings("unchecked") Map params, TemplateModel[] loopVars, - TemplateDirectiveBody body) throws TemplateException, IOException { - Object name = params.get(PARAM_NAME); - if (name == null) { - throw new IllegalArgumentException("params[" + PARAM_NAME + "]"); - } - if (!SimpleScalar.class.isInstance(name)) { - throw new IllegalArgumentException("params[" + PARAM_NAME + "]"); - } - Object rootModel = params.get(PARAM_ROOT_MODEL); - if (rootModel == null) { - throw new IllegalArgumentException("params[" + PARAM_ROOT_MODEL + "]"); - } - Template template = env.getTemplateForInclusion(((SimpleScalar) name).getAsString(), null, true); - template.process(rootModel, env.getOut()); - if (body != null) { - body.render(env.getOut()); - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.generator.impl; + +import java.io.IOException; +import java.util.Map; + +import freemarker.core.Environment; +import freemarker.template.SimpleScalar; +import freemarker.template.Template; +import freemarker.template.TemplateDirectiveBody; +import freemarker.template.TemplateDirectiveModel; +import freemarker.template.TemplateException; +import freemarker.template.TemplateModel; + +/** + * インクルードのディレクティブ。 + * <p> + * インクルード先のテンプレートで任意のオブジェクトをルートのデータモデルに指定できます。 + * </p> + * + * @author j5ik2o + */ +public class IncludeDirective implements TemplateDirectiveModel { + + /** インクルードするテンプレート名のパラメータ名 */ + protected static final String PARAM_NAME = "name"; + + /** ルートモデルのパラメータ名 */ + protected static final String PARAM_ROOT_MODEL = "rootModel"; + + + public void execute(Environment env, @SuppressWarnings("unchecked") Map params, TemplateModel[] loopVars, + TemplateDirectiveBody body) throws TemplateException, IOException { + Object name = params.get(PARAM_NAME); + if (name == null) { + throw new IllegalArgumentException("params[" + PARAM_NAME + "]"); + } + if (!SimpleScalar.class.isInstance(name)) { + throw new IllegalArgumentException("params[" + PARAM_NAME + "]"); + } + Object rootModel = params.get(PARAM_ROOT_MODEL); + if (rootModel == null) { + throw new IllegalArgumentException("params[" + PARAM_ROOT_MODEL + "]"); + } + Template template = env.getTemplateForInclusion(((SimpleScalar) name).getAsString(), null, true); + template.process(rootModel, env.getOut()); + if (body != null) { + body.render(env.getOut()); + } + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/IncludeDirective.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/OnDemandDateModel.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/OnDemandDateModel.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/OnDemandDateModel.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,40 +1,40 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.generator.impl; - -import java.util.Date; - -import freemarker.template.TemplateDateModel; -import freemarker.template.TemplateModelException; - -/** - * 必要とされるたびに{@link Date}を生成する{@link TemplateDateModel}の実装。 - * - * @author j5ik2o - */ -public class OnDemandDateModel implements TemplateDateModel { - - public Date getAsDate() throws TemplateModelException { - return new Date(); - } - - public int getDateType() { - return UNKNOWN; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.generator.impl; + +import java.util.Date; + +import freemarker.template.TemplateDateModel; +import freemarker.template.TemplateModelException; + +/** + * 必要とされるたびに{@link Date}を生成する{@link TemplateDateModel}の実装。 + * + * @author j5ik2o + */ +public class OnDemandDateModel implements TemplateDateModel { + + public Date getAsDate() throws TemplateModelException { + return new Date(); + } + + public int getDateType() { + return UNKNOWN; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/OnDemandDateModel.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/ResourceTemplateLoader.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/ResourceTemplateLoader.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/ResourceTemplateLoader.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,62 +1,62 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.generator.impl; - -import java.net.URL; - -import freemarker.cache.TemplateLoader; -import freemarker.cache.URLTemplateLoader; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.utils.ResourceUtil; - -/** - * リソースを扱う{@link TemplateLoader}の実装クラス。 - * <p> - * JARファイルに含まれたリソースを扱う。 - * </p> - * - * @author j5ik2o - */ -public class ResourceTemplateLoader extends URLTemplateLoader { - - /** ベースとなるパス */ - protected String basePath; - - - /** - * インスタンスを生成する。 - * - * @param basePath ベースとなるパス - */ - public ResourceTemplateLoader(String basePath) { - Validate.notNull(basePath); - this.basePath = basePath; - } - - @Override - protected URL getURL(String name) { - Validate.notNull(name); - String path = basePath + "/" + name; - URL result = ResourceUtil.getResourceNoException(path); - return result; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.generator.impl; + +import java.net.URL; + +import freemarker.cache.TemplateLoader; +import freemarker.cache.URLTemplateLoader; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.utils.ResourceUtil; + +/** + * リソースを扱う{@link TemplateLoader}の実装クラス。 + * <p> + * JARファイルに含まれたリソースを扱う。 + * </p> + * + * @author j5ik2o + */ +public class ResourceTemplateLoader extends URLTemplateLoader { + + /** ベースとなるパス */ + protected String basePath; + + + /** + * インスタンスを生成する。 + * + * @param basePath ベースとなるパス + */ + public ResourceTemplateLoader(String basePath) { + Validate.notNull(basePath); + this.basePath = basePath; + } + + @Override + protected URL getURL(String name) { + Validate.notNull(name); + String path = basePath + "/" + name; + URL result = ResourceUtil.getResourceNoException(path); + return result; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/generator/impl/ResourceTemplateLoader.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbColumnMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbColumnMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbColumnMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,261 +1,261 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.meta; - -/** - * データベースのカラムメタデータです。 - * - * @author j5ik2o - */ -public class DbColumnMeta { - - /** 名前 */ - protected String name; - - /** SQL型 */ - protected int sqlType; - - /** 型名 */ - protected String typeName; - - /** 長さ */ - protected int length; - - /** スケール */ - protected int scale; - - /** デフォルト値 */ - protected String defaultValue; - - /** NULL可能の場合{@code true} */ - protected boolean nullable; - - /** 主キーの場合{@code true} */ - protected boolean primaryKey; - - /** 値が自動的に増分される場合{@code true} */ - protected boolean autoIncrement; - - /** 一意の場合{@code true} */ - protected boolean unique; - - /** コメント */ - protected String comment; - - - /** - * コメントを取得する。 - * - * @return コメント - */ - public String getComment() { - return comment; - } - - /** - * デフォルト値を取得する。 - * - * @return デフォルト値 - */ - public String getDefaultValue() { - return defaultValue; - } - - /** - * 長さを取得する。 - * - * @return 長さ - */ - public int getLength() { - return length; - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return name; - } - - /** - * スケールを取得する。 - * - * @return スケール - */ - public int getScale() { - return scale; - } - - /** - * SQL型を取得する。 - * - * @return SQL型 - */ - public int getSqlType() { - return sqlType; - } - - /** - * 型名を取得する。 - * - * @return 型名 - */ - public String getTypeName() { - return typeName; - } - - /** - * 値が自動的に増分される場合{@code true}を取得する。 - * - * @return 値が自動的に増分される場合{@code true}、そうでない場合{@code false} - */ - public boolean isAutoIncrement() { - return autoIncrement; - } - - /** - * NULL可能の場合{@code true}を取得する。 - * - * @return NULL可能の場合{@code true}、そうでない場合{@code false} - */ - public boolean isNullable() { - return nullable; - } - - /** - * 主キーの場合{@code true}を取得する。 - * - * @return 主キーの場合{@code true}、そうでない場合{@code false} - */ - public boolean isPrimaryKey() { - return primaryKey; - } - - /** - * 一意の場合{@code true}、そうでない場合{@code false}を取得する。 - * - * @return 一意の場合{@code true}、そうでない場合{@code false} - */ - public boolean isUnique() { - return unique; - } - - /** - * 値が自動的に増分される場合{@code true}を設定する。 - * - * @param autoIncrement 値が自動的に増分される場合{@code true}、そうでない場合{@code false} - */ - public void setAutoIncrement(boolean autoIncrement) { - this.autoIncrement = autoIncrement; - } - - /** - * コメントを設定する。 - * - * @param comment コメント - */ - public void setComment(String comment) { - this.comment = comment; - } - - /** - * デフォルト値を設定する - * - * @param defaultValue デフォルト値 - */ - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - /** - * 長さを設定する。 - * - * @param length 長さ - */ - public void setLength(int length) { - this.length = length; - } - - /** - * 名前を設定する。 - * - * @param name 名前 - */ - public void setName(String name) { - this.name = name; - } - - /** - * NULL可能の場合{@code true}を設定する。 - * - * @param nullable NULL可能の場合{@code true} - */ - public void setNullable(boolean nullable) { - this.nullable = nullable; - } - - /** - * 主キーの場合 {@code true}を設定する。 - * - * @param primaryKey 主キーの場合 {@code true} - * - */ - public void setPrimaryKey(boolean primaryKey) { - this.primaryKey = primaryKey; - } - - /** - * スケールを設定する。 - * - * @param scale スケール - */ - public void setScale(int scale) { - this.scale = scale; - } - - /** - * SQL型をセットする。 - * - * @param sqlType SQL型 - */ - public void setSqlType(int sqlType) { - this.sqlType = sqlType; - } - - /** - * SQL型の名前を設定する。 - * - * @param typeName SQL型の名前 - */ - public void setTypeName(String typeName) { - this.typeName = typeName; - } - - /** - * 一意の場合{@code true}、そうでない場合{@code false}を設定する。 - * - * @param unique 一意の場合{@code true} - */ - public void setUnique(boolean unique) { - this.unique = unique; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.meta; + +/** + * データベースのカラムメタデータです。 + * + * @author j5ik2o + */ +public class DbColumnMeta { + + /** 名前 */ + protected String name; + + /** SQL型 */ + protected int sqlType; + + /** 型名 */ + protected String typeName; + + /** 長さ */ + protected int length; + + /** スケール */ + protected int scale; + + /** デフォルト値 */ + protected String defaultValue; + + /** NULL可能の場合{@code true} */ + protected boolean nullable; + + /** 主キーの場合{@code true} */ + protected boolean primaryKey; + + /** 値が自動的に増分される場合{@code true} */ + protected boolean autoIncrement; + + /** 一意の場合{@code true} */ + protected boolean unique; + + /** コメント */ + protected String comment; + + + /** + * コメントを取得する。 + * + * @return コメント + */ + public String getComment() { + return comment; + } + + /** + * デフォルト値を取得する。 + * + * @return デフォルト値 + */ + public String getDefaultValue() { + return defaultValue; + } + + /** + * 長さを取得する。 + * + * @return 長さ + */ + public int getLength() { + return length; + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return name; + } + + /** + * スケールを取得する。 + * + * @return スケール + */ + public int getScale() { + return scale; + } + + /** + * SQL型を取得する。 + * + * @return SQL型 + */ + public int getSqlType() { + return sqlType; + } + + /** + * 型名を取得する。 + * + * @return 型名 + */ + public String getTypeName() { + return typeName; + } + + /** + * 値が自動的に増分される場合{@code true}を取得する。 + * + * @return 値が自動的に増分される場合{@code true}、そうでない場合{@code false} + */ + public boolean isAutoIncrement() { + return autoIncrement; + } + + /** + * NULL可能の場合{@code true}を取得する。 + * + * @return NULL可能の場合{@code true}、そうでない場合{@code false} + */ + public boolean isNullable() { + return nullable; + } + + /** + * 主キーの場合{@code true}を取得する。 + * + * @return 主キーの場合{@code true}、そうでない場合{@code false} + */ + public boolean isPrimaryKey() { + return primaryKey; + } + + /** + * 一意の場合{@code true}、そうでない場合{@code false}を取得する。 + * + * @return 一意の場合{@code true}、そうでない場合{@code false} + */ + public boolean isUnique() { + return unique; + } + + /** + * 値が自動的に増分される場合{@code true}を設定する。 + * + * @param autoIncrement 値が自動的に増分される場合{@code true}、そうでない場合{@code false} + */ + public void setAutoIncrement(boolean autoIncrement) { + this.autoIncrement = autoIncrement; + } + + /** + * コメントを設定する。 + * + * @param comment コメント + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** + * デフォルト値を設定する + * + * @param defaultValue デフォルト値 + */ + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + /** + * 長さを設定する。 + * + * @param length 長さ + */ + public void setLength(int length) { + this.length = length; + } + + /** + * 名前を設定する。 + * + * @param name 名前 + */ + public void setName(String name) { + this.name = name; + } + + /** + * NULL可能の場合{@code true}を設定する。 + * + * @param nullable NULL可能の場合{@code true} + */ + public void setNullable(boolean nullable) { + this.nullable = nullable; + } + + /** + * 主キーの場合 {@code true}を設定する。 + * + * @param primaryKey 主キーの場合 {@code true} + * + */ + public void setPrimaryKey(boolean primaryKey) { + this.primaryKey = primaryKey; + } + + /** + * スケールを設定する。 + * + * @param scale スケール + */ + public void setScale(int scale) { + this.scale = scale; + } + + /** + * SQL型をセットする。 + * + * @param sqlType SQL型 + */ + public void setSqlType(int sqlType) { + this.sqlType = sqlType; + } + + /** + * SQL型の名前を設定する。 + * + * @param typeName SQL型の名前 + */ + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + /** + * 一意の場合{@code true}、そうでない場合{@code false}を設定する。 + * + * @param unique 一意の場合{@code true} + */ + public void setUnique(boolean unique) { + this.unique = unique; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbColumnMeta.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbForeignKeyMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbForeignKeyMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbForeignKeyMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,204 +1,204 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.meta; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * データベースの外部キーメタデータ。 - * - * @author j5ik2o - */ -public class DbForeignKeyMeta { - - /** 名前 */ - protected String name; - - /** 主キー側のカタログ名 */ - protected String primaryKeyCatalogName; - - /** 主キー側のスキーマ名 */ - protected String primaryKeySchemaName; - - /** 主キー側のテーブル名 */ - protected String primaryKeyTableName; - - /** 主キーのカラム名のリスト */ - protected List<String> primaryKeyColumnNameList = new ArrayList<String>(); - - /** 外部キーのカラム名のリスト */ - protected List<String> foreignKeyColumnNameList = new ArrayList<String>(); - - /** 一意の場合{@code true} */ - protected boolean unique; - - - /** - * 外部キーのカラム名を追加する。 - * - * @param foreignKeyColumnName 外部キーのカラム名 - */ - public void addForeignKeyColumnName(String foreignKeyColumnName) { - foreignKeyColumnNameList.add(foreignKeyColumnName); - } - - /** - * 主キーのカラム名を追加する。 - * - * @param primaryKeyColumnName 主キーのカラム名 - */ - public void addPrimaryKeyColumnName(String primaryKeyColumnName) { - primaryKeyColumnNameList.add(primaryKeyColumnName); - } - - /** - * 外部キーのカラム名のリストを取得する。 - * - * @return 外部キーのカラム名のリスト - */ - public List<String> getForeignKeyColumnNameList() { - return Collections.unmodifiableList(foreignKeyColumnNameList); - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return name; - } - - /** - * 主キー側のカタログ名を取得する。 - * - * @return 主キー側のカタログ名 - */ - public String getPrimaryKeyCatalogName() { - return primaryKeyCatalogName; - } - - /** - * 主キーのカラム名のリストを取得する。 - * - * @return 主キーのカラム名のリスト - */ - public List<String> getPrimaryKeyColumnNameList() { - return Collections.unmodifiableList(primaryKeyColumnNameList); - } - - /** - * 完全なテーブル名を取得する。 - * - * @return 完全なテーブル名 - */ - public String getPrimaryKeyFullTableName() { - StringBuilder buf = new StringBuilder(); - if (primaryKeyCatalogName != null) { - buf.append(primaryKeyCatalogName).append("."); - } - if (primaryKeySchemaName != null) { - buf.append(primaryKeySchemaName).append("."); - } - return buf.append(primaryKeyTableName).toString(); - } - - /** - * 主キー側のスキーマ名を取得する。 - * - * @return 主キー側のスキーマ名 - */ - public String getPrimaryKeySchemaName() { - return primaryKeySchemaName; - } - - /** - * 主キー側のテーブル名を取得する。 - * - * @return 主キー側のテーブル名 - */ - public String getPrimaryKeyTableName() { - return primaryKeyTableName; - } - - /** - * 複合外部キーの場合{@code true}、そうでない場合{@code false}を取得する。 - * - * @return 複合外部キーの場合{@code true}、そうでない場合{@code false} - */ - public boolean isComposite() { - return foreignKeyColumnNameList.size() > 1; - } - - /** - * 一意の場合{@code true}、そうでない場合{@code false}を取得する。 - * - * @return 一意の場合{@code true}、そうでない場合{@code false} - */ - public boolean isUnique() { - return unique; - } - - /** - * 名前を設定する。 - * - * @param name 名前 - */ - public void setName(String name) { - this.name = name; - } - - /** - * 主キー側のカタログ名を設定する。 - * - * @param primaryKeyCatalogName 主キー側のカタログ名 - */ - public void setPrimaryKeyCatalogName(String primaryKeyCatalogName) { - this.primaryKeyCatalogName = primaryKeyCatalogName; - } - - /** - * 主キー側のスキーマ名を設定する。 - * - * @param primaryKeySchemaName 主キー側のスキーマ名 - */ - public void setPrimaryKeySchemaName(String primaryKeySchemaName) { - this.primaryKeySchemaName = primaryKeySchemaName; - } - - /** - * 主キー側のテーブル名を設定する。 - * - * @param primaryKeyTableName 主キー側のテーブル名 - */ - public void setPrimaryKeyTableName(String primaryKeyTableName) { - this.primaryKeyTableName = primaryKeyTableName; - } - - /** - * 一意の場合{@code true}、そうでない場合{@code false}を設定する。 - * - * @param unique 一意の場合{@code true} - */ - public void setUnique(boolean unique) { - this.unique = unique; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.meta; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * データベースの外部キーメタデータ。 + * + * @author j5ik2o + */ +public class DbForeignKeyMeta { + + /** 名前 */ + protected String name; + + /** 主キー側のカタログ名 */ + protected String primaryKeyCatalogName; + + /** 主キー側のスキーマ名 */ + protected String primaryKeySchemaName; + + /** 主キー側のテーブル名 */ + protected String primaryKeyTableName; + + /** 主キーのカラム名のリスト */ + protected List<String> primaryKeyColumnNameList = new ArrayList<String>(); + + /** 外部キーのカラム名のリスト */ + protected List<String> foreignKeyColumnNameList = new ArrayList<String>(); + + /** 一意の場合{@code true} */ + protected boolean unique; + + + /** + * 外部キーのカラム名を追加する。 + * + * @param foreignKeyColumnName 外部キーのカラム名 + */ + public void addForeignKeyColumnName(String foreignKeyColumnName) { + foreignKeyColumnNameList.add(foreignKeyColumnName); + } + + /** + * 主キーのカラム名を追加する。 + * + * @param primaryKeyColumnName 主キーのカラム名 + */ + public void addPrimaryKeyColumnName(String primaryKeyColumnName) { + primaryKeyColumnNameList.add(primaryKeyColumnName); + } + + /** + * 外部キーのカラム名のリストを取得する。 + * + * @return 外部キーのカラム名のリスト + */ + public List<String> getForeignKeyColumnNameList() { + return Collections.unmodifiableList(foreignKeyColumnNameList); + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return name; + } + + /** + * 主キー側のカタログ名を取得する。 + * + * @return 主キー側のカタログ名 + */ + public String getPrimaryKeyCatalogName() { + return primaryKeyCatalogName; + } + + /** + * 主キーのカラム名のリストを取得する。 + * + * @return 主キーのカラム名のリスト + */ + public List<String> getPrimaryKeyColumnNameList() { + return Collections.unmodifiableList(primaryKeyColumnNameList); + } + + /** + * 完全なテーブル名を取得する。 + * + * @return 完全なテーブル名 + */ + public String getPrimaryKeyFullTableName() { + StringBuilder buf = new StringBuilder(); + if (primaryKeyCatalogName != null) { + buf.append(primaryKeyCatalogName).append("."); + } + if (primaryKeySchemaName != null) { + buf.append(primaryKeySchemaName).append("."); + } + return buf.append(primaryKeyTableName).toString(); + } + + /** + * 主キー側のスキーマ名を取得する。 + * + * @return 主キー側のスキーマ名 + */ + public String getPrimaryKeySchemaName() { + return primaryKeySchemaName; + } + + /** + * 主キー側のテーブル名を取得する。 + * + * @return 主キー側のテーブル名 + */ + public String getPrimaryKeyTableName() { + return primaryKeyTableName; + } + + /** + * 複合外部キーの場合{@code true}、そうでない場合{@code false}を取得する。 + * + * @return 複合外部キーの場合{@code true}、そうでない場合{@code false} + */ + public boolean isComposite() { + return foreignKeyColumnNameList.size() > 1; + } + + /** + * 一意の場合{@code true}、そうでない場合{@code false}を取得する。 + * + * @return 一意の場合{@code true}、そうでない場合{@code false} + */ + public boolean isUnique() { + return unique; + } + + /** + * 名前を設定する。 + * + * @param name 名前 + */ + public void setName(String name) { + this.name = name; + } + + /** + * 主キー側のカタログ名を設定する。 + * + * @param primaryKeyCatalogName 主キー側のカタログ名 + */ + public void setPrimaryKeyCatalogName(String primaryKeyCatalogName) { + this.primaryKeyCatalogName = primaryKeyCatalogName; + } + + /** + * 主キー側のスキーマ名を設定する。 + * + * @param primaryKeySchemaName 主キー側のスキーマ名 + */ + public void setPrimaryKeySchemaName(String primaryKeySchemaName) { + this.primaryKeySchemaName = primaryKeySchemaName; + } + + /** + * 主キー側のテーブル名を設定する。 + * + * @param primaryKeyTableName 主キー側のテーブル名 + */ + public void setPrimaryKeyTableName(String primaryKeyTableName) { + this.primaryKeyTableName = primaryKeyTableName; + } + + /** + * 一意の場合{@code true}、そうでない場合{@code false}を設定する。 + * + * @param unique 一意の場合{@code true} + */ + public void setUnique(boolean unique) { + this.unique = unique; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbForeignKeyMeta.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbTableMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbTableMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbTableMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,224 +1,224 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.meta; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * データベースのテーブルメタデータ。 - * - * @author j5ik2o - */ -public class DbTableMeta { - - /** カタログ名 */ - protected String catalogName; - - /** スキーマ名 */ - protected String schemaName; - - /** 名前 */ - protected String name; - - /** 完全な名前 */ - protected String fullName; - - /** コメント */ - protected String comment; - - /** カラムメタデータのリスト */ - protected List<DbColumnMeta> columnMetaList = new ArrayList<DbColumnMeta>(); - - /** 主キーのカラムメタデータのリスト */ - protected List<DbColumnMeta> primaryKeyColumnMetaList = new ArrayList<DbColumnMeta>(); - - /** 外部キーメタデータのリスト */ - protected List<DbForeignKeyMeta> foreignKeyMetaList = new ArrayList<DbForeignKeyMeta>(); - - /** 一意キーメタデータのリスト */ - protected List<DbUniqueKeyMeta> uniqueKeyMetaList = new ArrayList<DbUniqueKeyMeta>(); - - - /** - * カラムのメタデータを追加する。 - * - * @param columnMeta カラム記述 - */ - public void addColumnMeta(DbColumnMeta columnMeta) { - columnMetaList.add(columnMeta); - if (columnMeta.isPrimaryKey()) { - primaryKeyColumnMetaList.add(columnMeta); - } - } - - /** - * 外部キーメタデータを追加する。 - * - * @param foreignKeyMeta 外部キーメタデータ - */ - public void addForeignKeyMeta(DbForeignKeyMeta foreignKeyMeta) { - foreignKeyMetaList.add(foreignKeyMeta); - } - - /** - * 一意キーメタデータを追加する。 - * - * @param uniqueKeyMeta 一意キーメタデータ - */ - public void addUniqueKeyMeta(DbUniqueKeyMeta uniqueKeyMeta) { - uniqueKeyMetaList.add(uniqueKeyMeta); - } - - /** - * カタログ名を取得する。 - * - * @return カタログ名 - */ - public String getCatalogName() { - return catalogName; - } - - /** - * カラムのメタデータのリストを取得する。 - * - * @return カラムのメタデータのリスト - */ - public List<DbColumnMeta> getColumnMetaList() { - return Collections.unmodifiableList(columnMetaList); - } - - /** - * コメントを取得する。 - * - * @return コメント - */ - public String getComment() { - return comment; - } - - /** - * 外部キーメタデータのリストを取得する。 - * - * @return 外部キーメタデータのリスト - */ - public List<DbForeignKeyMeta> getForeignKeyMetaList() { - return Collections.unmodifiableList(foreignKeyMetaList); - } - - /** - * 完全なテーブル名を取得する。 - * - * @return 完全なテーブル名 - */ - public String getFullName() { - return fullName; - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return name; - } - - /** - * 主キーのカラムメタデータのリストを取得する。 - * - * @return 主キーのカラムメタデータのリスト - */ - public List<DbColumnMeta> getPrimaryKeyColumnMetaList() { - return Collections.unmodifiableList(primaryKeyColumnMetaList); - } - - /** - * スキーマ名を取得する。 - * - * @return スキーマ名 - */ - public String getSchemaName() { - return schemaName; - } - - /** - * 一意キーメタデータのリストを取得する。 - * - * @return 一意キーメタデータのリスト - */ - public List<DbUniqueKeyMeta> getUniqueKeyMetaList() { - return Collections.unmodifiableList(uniqueKeyMetaList); - } - - /** - * 複合主キーを持つ場合{@code true}を取得する。 - * - * @return 複合主キーを持つ場合{@code true}、そうでない場合{@code false} - */ - public boolean hasCompositePrimaryKey() { - return primaryKeyColumnMetaList.size() > 1; - } - - /** - * カタログ名を設定する。 - * - * @param catalogName カタログ名 - */ - public void setCatalogName(String catalogName) { - this.catalogName = catalogName; - } - - /** - * コメントを設定する。 - * - * @param comment コメント - */ - public void setComment(String comment) { - this.comment = comment; - } - - /** - * 完全な名前を設定する。 - * - * @param fullName 完全な名前 - */ - public void setFullName(String fullName) { - this.fullName = fullName; - } - - /** - * 名前を設定する。 - * - * @param name 名前 - */ - public void setName(String name) { - this.name = name; - } - - /** - * スキーマ名を設定する。 - * - * @param schemaName スキーマ名 - */ - public void setSchemaName(String schemaName) { - this.schemaName = schemaName; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.meta; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * データベースのテーブルメタデータ。 + * + * @author j5ik2o + */ +public class DbTableMeta { + + /** カタログ名 */ + protected String catalogName; + + /** スキーマ名 */ + protected String schemaName; + + /** 名前 */ + protected String name; + + /** 完全な名前 */ + protected String fullName; + + /** コメント */ + protected String comment; + + /** カラムメタデータのリスト */ + protected List<DbColumnMeta> columnMetaList = new ArrayList<DbColumnMeta>(); + + /** 主キーのカラムメタデータのリスト */ + protected List<DbColumnMeta> primaryKeyColumnMetaList = new ArrayList<DbColumnMeta>(); + + /** 外部キーメタデータのリスト */ + protected List<DbForeignKeyMeta> foreignKeyMetaList = new ArrayList<DbForeignKeyMeta>(); + + /** 一意キーメタデータのリスト */ + protected List<DbUniqueKeyMeta> uniqueKeyMetaList = new ArrayList<DbUniqueKeyMeta>(); + + + /** + * カラムのメタデータを追加する。 + * + * @param columnMeta カラム記述 + */ + public void addColumnMeta(DbColumnMeta columnMeta) { + columnMetaList.add(columnMeta); + if (columnMeta.isPrimaryKey()) { + primaryKeyColumnMetaList.add(columnMeta); + } + } + + /** + * 外部キーメタデータを追加する。 + * + * @param foreignKeyMeta 外部キーメタデータ + */ + public void addForeignKeyMeta(DbForeignKeyMeta foreignKeyMeta) { + foreignKeyMetaList.add(foreignKeyMeta); + } + + /** + * 一意キーメタデータを追加する。 + * + * @param uniqueKeyMeta 一意キーメタデータ + */ + public void addUniqueKeyMeta(DbUniqueKeyMeta uniqueKeyMeta) { + uniqueKeyMetaList.add(uniqueKeyMeta); + } + + /** + * カタログ名を取得する。 + * + * @return カタログ名 + */ + public String getCatalogName() { + return catalogName; + } + + /** + * カラムのメタデータのリストを取得する。 + * + * @return カラムのメタデータのリスト + */ + public List<DbColumnMeta> getColumnMetaList() { + return Collections.unmodifiableList(columnMetaList); + } + + /** + * コメントを取得する。 + * + * @return コメント + */ + public String getComment() { + return comment; + } + + /** + * 外部キーメタデータのリストを取得する。 + * + * @return 外部キーメタデータのリスト + */ + public List<DbForeignKeyMeta> getForeignKeyMetaList() { + return Collections.unmodifiableList(foreignKeyMetaList); + } + + /** + * 完全なテーブル名を取得する。 + * + * @return 完全なテーブル名 + */ + public String getFullName() { + return fullName; + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return name; + } + + /** + * 主キーのカラムメタデータのリストを取得する。 + * + * @return 主キーのカラムメタデータのリスト + */ + public List<DbColumnMeta> getPrimaryKeyColumnMetaList() { + return Collections.unmodifiableList(primaryKeyColumnMetaList); + } + + /** + * スキーマ名を取得する。 + * + * @return スキーマ名 + */ + public String getSchemaName() { + return schemaName; + } + + /** + * 一意キーメタデータのリストを取得する。 + * + * @return 一意キーメタデータのリスト + */ + public List<DbUniqueKeyMeta> getUniqueKeyMetaList() { + return Collections.unmodifiableList(uniqueKeyMetaList); + } + + /** + * 複合主キーを持つ場合{@code true}を取得する。 + * + * @return 複合主キーを持つ場合{@code true}、そうでない場合{@code false} + */ + public boolean hasCompositePrimaryKey() { + return primaryKeyColumnMetaList.size() > 1; + } + + /** + * カタログ名を設定する。 + * + * @param catalogName カタログ名 + */ + public void setCatalogName(String catalogName) { + this.catalogName = catalogName; + } + + /** + * コメントを設定する。 + * + * @param comment コメント + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** + * 完全な名前を設定する。 + * + * @param fullName 完全な名前 + */ + public void setFullName(String fullName) { + this.fullName = fullName; + } + + /** + * 名前を設定する。 + * + * @param name 名前 + */ + public void setName(String name) { + this.name = name; + } + + /** + * スキーマ名を設定する。 + * + * @param schemaName スキーマ名 + */ + public void setSchemaName(String schemaName) { + this.schemaName = schemaName; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbTableMeta.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbTableMetaReader.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbTableMetaReader.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbTableMetaReader.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,36 +1,36 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.meta; - -import java.util.List; - -/** - * {@link DbTableMeta データベースのテーブルメタデータ}を読み取るインタフェース。 - * - * @author j5ik2o - */ -public interface DbTableMetaReader { - - /** - * データベースのテーブルメタデータを読み取る。 - * - * @return テーブルメタデータのリスト - */ - List<DbTableMeta> read(); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.meta; + +import java.util.List; + +/** + * {@link DbTableMeta データベースのテーブルメタデータ}を読み取るインタフェース。 + * + * @author j5ik2o + */ +public interface DbTableMetaReader { + + /** + * データベースのテーブルメタデータを読み取る。 + * + * @return テーブルメタデータのリスト + */ + List<DbTableMeta> read(); +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbTableMetaReader.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbUniqueKeyMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbUniqueKeyMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbUniqueKeyMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,105 +1,105 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.meta; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * データベースの一意キーメタデータ。 - * - * @author j5ik2o - */ -public class DbUniqueKeyMeta { - - /** 名前 */ - protected String name; - - /** 主キーの場合{@code true} */ - protected boolean primaryKey; - - /** カラム名 */ - protected List<String> columnNameList = new ArrayList<String>(); - - - /** - * カラム名を追加する。 - * - * @param columnName カラム名 - */ - public void addColumnName(String columnName) { - columnNameList.add(columnName); - } - - /** - * カラム名のリストを取得する。 - * - * @return カラム名のリスト - */ - public List<String> getColumnNameList() { - return Collections.unmodifiableList(columnNameList); - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return name; - } - - /** - * 複合一意キーの場合{@code true}、そうでない場合{@code false}を取得する。 - * - * @return 複合一意キーの場合{@code true}、そうでない場合{@code false} - */ - public boolean isComposite() { - return columnNameList.size() > 1; - } - - /** - * 主キーの場合{@code true}、そうでない場合{@code false}を取得する。 - * - * @return 主キーの場合{@code true}、そうでない場合{@code false} - */ - public boolean isPrimaryKey() { - return primaryKey; - } - - /** - * 名前を設定する。 - * - * @param name 名前 - */ - public void setName(String name) { - this.name = name; - } - - /** - * 主キーの場合{@code true}、そうでない場合{@code false}を設定する。 - * - * @param primaryKey 主キーの場合{@code true}、そうでない場合{@code false} - */ - public void setPrimaryKey(boolean primaryKey) { - this.primaryKey = primaryKey; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.meta; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * データベースの一意キーメタデータ。 + * + * @author j5ik2o + */ +public class DbUniqueKeyMeta { + + /** 名前 */ + protected String name; + + /** 主キーの場合{@code true} */ + protected boolean primaryKey; + + /** カラム名 */ + protected List<String> columnNameList = new ArrayList<String>(); + + + /** + * カラム名を追加する。 + * + * @param columnName カラム名 + */ + public void addColumnName(String columnName) { + columnNameList.add(columnName); + } + + /** + * カラム名のリストを取得する。 + * + * @return カラム名のリスト + */ + public List<String> getColumnNameList() { + return Collections.unmodifiableList(columnNameList); + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return name; + } + + /** + * 複合一意キーの場合{@code true}、そうでない場合{@code false}を取得する。 + * + * @return 複合一意キーの場合{@code true}、そうでない場合{@code false} + */ + public boolean isComposite() { + return columnNameList.size() > 1; + } + + /** + * 主キーの場合{@code true}、そうでない場合{@code false}を取得する。 + * + * @return 主キーの場合{@code true}、そうでない場合{@code false} + */ + public boolean isPrimaryKey() { + return primaryKey; + } + + /** + * 名前を設定する。 + * + * @param name 名前 + */ + public void setName(String name) { + this.name = name; + } + + /** + * 主キーの場合{@code true}、そうでない場合{@code false}を設定する。 + * + * @param primaryKey 主キーの場合{@code true}、そうでない場合{@code false} + */ + public void setPrimaryKey(boolean primaryKey) { + this.primaryKey = primaryKey; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/DbUniqueKeyMeta.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/impl/DbTableMetaReaderImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/impl/DbTableMetaReaderImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/impl/DbTableMetaReaderImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,450 +1,450 @@ -/* - * Copyright 2004-2009 the Seasar Foundation and the Others. - * - * 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.jiemamy.entity.io.gen.meta.impl; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.regex.Pattern; - -import javax.sql.DataSource; - -import org.jiemamy.entity.io.gen.dialect.GenDialect; -import org.jiemamy.entity.io.gen.meta.DbColumnMeta; -import org.jiemamy.entity.io.gen.meta.DbForeignKeyMeta; -import org.jiemamy.entity.io.gen.meta.DbTableMeta; -import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; -import org.jiemamy.entity.io.gen.meta.DbUniqueKeyMeta; - -/** - * {@code DbTableMetaReader}の実装クラスです。 - * - * @author taedium - */ -public class DbTableMetaReaderImpl implements DbTableMetaReader { - - /** ロガー */ - - /** データソース */ - protected DataSource dataSource; - - /** 方言 */ - protected GenDialect dialect; - - /** スキーマ名 */ - protected String schemaName; - - /** 読み取り対象とするテーブル名のパターン */ - protected Pattern tableNamePattern; - - /** 読み取り非対象とするテーブル名のパターン */ - protected Pattern ignoreTableNamePattern; - - /** コメントを読む場合{@code true} */ - protected boolean readComment; - - - /** - * インスタンスを構築します。 - * - * @param dataSource - * データソース - * @param dialect - * 方言 - * @param schemaName - * スキーマ名、デフォルトのスキーマ名を表す場合は{@code null} - * @param tableNamePattern - * 対象とするテーブル名の正規表現 - * @param ignoreTableNamePattern - * 対象としないテーブル名の正規表現 - * @param readComment - * コメントを読む場合{@code true} - */ - public DbTableMetaReaderImpl(DataSource dataSource, GenDialect dialect, String schemaName, String tableNamePattern, - String ignoreTableNamePattern, boolean readComment) { - if (dataSource == null) { - throw new NullPointerException("dataSource"); - } - if (dialect == null) { - throw new NullPointerException("dialect"); - } - if (tableNamePattern == null) { - throw new NullPointerException("tableNamePattern"); - } - if (ignoreTableNamePattern == null) { - throw new NullPointerException("ignoreTableNamePattern"); - } - this.dataSource = dataSource; - this.dialect = dialect; - this.schemaName = schemaName; - this.tableNamePattern = Pattern.compile(tableNamePattern, Pattern.CASE_INSENSITIVE); - this.ignoreTableNamePattern = Pattern.compile(ignoreTableNamePattern, Pattern.CASE_INSENSITIVE); - this.readComment = readComment; - } - - /** - * カラムメタデータを処理します。 - * - * @param metaData データベースメタデータ - * @param tableMeta テーブルメタデータ - * @param primaryKeySet 主キーのセット - */ - protected void doDbColumnMeta(DatabaseMetaData metaData, DbTableMeta tableMeta, Set<String> primaryKeySet) { - for (DbColumnMeta columnMeta : getDbColumnMetaList(metaData, tableMeta)) { - if (primaryKeySet.contains(columnMeta.getName())) { - columnMeta.setPrimaryKey(true); - if (primaryKeySet.size() == 1) { - columnMeta.setAutoIncrement(isAutoIncrement(metaData, tableMeta, columnMeta.getName())); - } - } - for (DbUniqueKeyMeta ukMeta : tableMeta.getUniqueKeyMetaList()) { - if (ukMeta.getColumnNameList().size() == 1) { - String ukColumnName = ukMeta.getColumnNameList().get(0); - if (columnMeta.getName().equals(ukColumnName)) { - columnMeta.setUnique(true); - } - } - } - tableMeta.addColumnMeta(columnMeta); - } - } - - /** - * 外部キーメタデータを処理する。 - * - * @param metaData データベースメタデータ - * @param tableMeta テーブルメタデータ - */ - protected void doDbForeignKeyMeta(DatabaseMetaData metaData, DbTableMeta tableMeta) { - for (DbForeignKeyMeta fkMeta : getDbForeignKeyMetaList(metaData, tableMeta)) { - for (DbUniqueKeyMeta ukMeta : tableMeta.getUniqueKeyMetaList()) { - if (fkMeta.getForeignKeyColumnNameList().equals(ukMeta.getColumnNameList())) { - fkMeta.setUnique(true); - } - } - tableMeta.addForeignKeyMeta(fkMeta); - } - } - - /** - * 一意キーメタデータを処理します。 - * - * @param metaData データベースメタデータ - * @param tableMeta テーブルメタデータ - * @param primaryKeySet 主キーのセット - */ - protected void doDbUniqueKeyMeta(DatabaseMetaData metaData, DbTableMeta tableMeta, Set<String> primaryKeySet) { - for (DbUniqueKeyMeta ukMeta : getDbUniqueKeyMetaList(metaData, tableMeta)) { - if (primaryKeySet.size() == ukMeta.getColumnNameList().size() - && primaryKeySet.containsAll(ukMeta.getColumnNameList())) { - ukMeta.setPrimaryKey(true); - } - tableMeta.addUniqueKeyMeta(ukMeta); - } - } - - /** - * カラムメタデータのリストを取得する。 - * - * @param metaData データベースメタデータ - * @param tableMeta テーブルメタデータ - * - * @return カラムメタデータのリスト - */ - protected List<DbColumnMeta> getDbColumnMetaList(DatabaseMetaData metaData, DbTableMeta tableMeta) { - List<DbColumnMeta> result = new ArrayList<DbColumnMeta>(); -// try { -// ResultSet rs = -// metaData.getColumns(tableMeta.getCatalogName(), tableMeta.getSchemaName(), tableMeta.getName(), -// null); -// try { -// while (rs.next()) { -// DbColumnMeta columnDesc = new DbColumnMeta(); -// columnDesc.setName(rs.getString("COLUMN_NAME")); -// columnDesc.setSqlType(rs.getInt("DATA_TYPE")); -// columnDesc.setTypeName(rs.getString("TYPE_NAME")); -// columnDesc.setLength(rs.getInt("COLUMN_SIZE")); -// columnDesc.setScale(rs.getInt("DECIMAL_DIGITS")); -// columnDesc.setNullable(rs.getBoolean("NULLABLE")); -// columnDesc.setDefaultValue(rs.getString("COLUMN_DEF")); -// if (readComment) { -// columnDesc.setComment(rs.getString("REMARKS")); -// } -// result.add(columnDesc); -// } -// return result; -// } finally { -// ResultSetUtil.close(rs); -// } -// } catch (SQLException ex) { -// throw new SQLRuntimeException(ex); -// } - return result; - } - - /** - * 外部キーメタデータのリストを返します。 - * - * @param metaData データベースメタデータ - * @param tableMeta テーブルメタデータ - * @return 外部キーメタデータのリスト - */ - protected List<DbForeignKeyMeta> getDbForeignKeyMetaList(DatabaseMetaData metaData, DbTableMeta tableMeta) { - return null; -// @SuppressWarnings("unchecked") -// Map<String, DbForeignKeyMeta> map = new ArrayMap(); -// try { -// ResultSet rs = -// metaData -// .getImportedKeys(tableMeta.getCatalogName(), tableMeta.getSchemaName(), tableMeta.getName()); -// try { -// while (rs.next()) { -// String name = rs.getString("FK_NAME"); -// if (!map.containsKey(name)) { -// DbForeignKeyMeta fkMeta = new DbForeignKeyMeta(); -// fkMeta.setName(name); -// fkMeta.setPrimaryKeyCatalogName(rs.getString("PKTABLE_CAT")); -// fkMeta.setPrimaryKeySchemaName(rs.getString("PKTABLE_SCHEM")); -// fkMeta.setPrimaryKeyTableName(rs.getString("PKTABLE_NAME")); -// map.put(name, fkMeta); -// } -// DbForeignKeyMeta fkMeta = map.get(name); -// fkMeta.addPrimaryKeyColumnName(rs.getString("PKCOLUMN_NAME")); -// fkMeta.addForeignKeyColumnName(rs.getString("FKCOLUMN_NAME")); -// } -// } finally { -// ResultSetUtil.close(rs); -// } -// DbForeignKeyMeta[] array = map.values().toArray(new DbForeignKeyMeta[map.size()]); -// return Arrays.asList(array); -// } catch (SQLException ex) { -// throw new SQLRuntimeException(ex); -// } - } - - /** - * テーブルメタデータのリストを返します。 - * - * @param metaData データベースメタデータ - * @param schemaName スキーマ名 - * @return テーブルメタデータのリスト - */ - protected List<DbTableMeta> getDbTableMetaList(DatabaseMetaData metaData, String schemaName) { - List<DbTableMeta> result = new ArrayList<DbTableMeta>(); -// try { -// ResultSet rs = metaData.getTables(null, schemaName, null, new String[] { -// "TABLE" -// }); -// try { -// while (rs.next()) { -// DbTableMeta dbTableMeta = new DbTableMeta(); -// dbTableMeta.setCatalogName(rs.getString("TABLE_CAT")); -// dbTableMeta.setSchemaName(rs.getString("TABLE_SCHEM")); -// dbTableMeta.setName(rs.getString("TABLE_NAME")); -// if (readComment) { -// dbTableMeta.setComment(rs.getString("REMARKS")); -// } -// if (isTargetTable(dbTableMeta)) { -// result.add(dbTableMeta); -// } -// } -// return result; -// } finally { -// ResultSetUtil.close(rs); -// } -// } catch (SQLException e) { -// throw new SQLRuntimeException(e); -// } - return result; - } - - /** - * 一意キーメタデータのリストを返します。 - * - * @param metaData データベースメタデータ - * @param tableMeta テーブルメタデータ - * @return 一意キーメタデータのリスト - */ - protected List<DbUniqueKeyMeta> getDbUniqueKeyMetaList(DatabaseMetaData metaData, DbTableMeta tableMeta) { - return null; -// if (!dialect.supportsGetIndexInfo(tableMeta.getCatalogName(), tableMeta.getSchemaName(), tableMeta.getName())) { -// logger.log("WS2JDBCGen0002", new Object[] { -// tableMeta.getCatalogName(), -// tableMeta.getSchemaName(), -// tableMeta.getName() -// }); -// return Collections.emptyList(); -// } -// -// @SuppressWarnings("unchecked") -// Map<String, DbUniqueKeyMeta> map = new ArrayMap(); -// try { -// ResultSet rs = -// metaData.getIndexInfo(tableMeta.getCatalogName(), tableMeta.getSchemaName(), tableMeta.getName(), -// true, false); -// try { -// while (rs.next()) { -// String name = rs.getString("INDEX_NAME"); -// if (!map.containsKey(name)) { -// DbUniqueKeyMeta ukMeta = new DbUniqueKeyMeta(); -// ukMeta.setName(name); -// map.put(name, ukMeta); -// } -// DbUniqueKeyMeta ukMeta = map.get(name); -// ukMeta.addColumnName(rs.getString("COLUMN_NAME")); -// } -// } finally { -// ResultSetUtil.close(rs); -// } -// DbUniqueKeyMeta[] array = map.values().toArray(new DbUniqueKeyMeta[map.size()]); -// return Arrays.asList(array); -// } catch (SQLException ex) { -// throw new SQLRuntimeException(ex); -// } - } - - /** - * デフォルトのスキーマ名を返します。 - * - * @param metaData データベースメタデータ - * @return デフォルトのスキーマ名 - */ - protected String getDefaultSchemaName(DatabaseMetaData metaData) { -// String userName = DatabaseMetaDataUtil.getUserName(metaData); -// return dialect.getDefaultSchemaName(userName); - return null; - } - - /** - * 主キーのセットを返します。 - * - * @param metaData データベースメタデータ - * @param tableMeta - * テーブルメタデータ - * @return 主キーのセット - */ - protected Set<String> getPrimaryKeySet(DatabaseMetaData metaData, DbTableMeta tableMeta) { - Set<String> result = new HashSet<String>(); -// try { -// ResultSet rs = -// metaData.getPrimaryKeys(tableMeta.getCatalogName(), tableMeta.getSchemaName(), tableMeta.getName()); -// try { -// while (rs.next()) { -// result.add(rs.getString("COLUMN_NAME")); -// } -// } finally { -// ResultSetUtil.close(rs); -// } -// return result; -// } catch (SQLException ex) { -// throw new SQLRuntimeException(ex); -// } - return result; - } - - /** - * 列の値が自動的に増分される場合{@code true}を返します。 - * - * @param metaData データベースメタデータ - * @param tableMeta テーブルメタデータ - * @param columnName カラム名 - * @return 列が自動的に増分される場合{@code true}、そうでない場合{@code false} - */ - protected boolean isAutoIncrement(DatabaseMetaData metaData, DbTableMeta tableMeta, String columnName) { -// try { -// return dialect.isAutoIncrement(metaData.getConnection(), tableMeta.getCatalogName(), tableMeta -// .getSchemaName(), tableMeta.getName(), columnName); -// } catch (SQLException ex) { -// throw new SQLRuntimeException(ex); -// } - return false; - } - - /** - * 読み取り対象のテーブルの場合{@code true}を返します。 - * - * @param dbTableMeta テーブルメタデータ - * @return 読み取り対象のテーブルの場合{@code true} - */ - protected boolean isTargetTable(DbTableMeta dbTableMeta) { - String name = dbTableMeta.getName(); - if (!tableNamePattern.matcher(name).matches()) { - return false; - } - if (ignoreTableNamePattern.matcher(name).matches()) { - return false; - } - return true; - } - - public List<DbTableMeta> read() { - return null; -// Connection con = DataSourceUtil.getConnection(dataSource); -// try { -// DatabaseMetaData metaData = ConnectionUtil.getMetaData(con); -// List<DbTableMeta> dbTableMetaList = -// getDbTableMetaList(metaData, schemaName != null ? schemaName : getDefaultSchemaName(metaData)); -// if (dbTableMetaList.isEmpty()) { -// throw new TableNotFoundRuntimeException(dialect.getClass().getName(), schemaName, tableNamePattern -// .pattern(), ignoreTableNamePattern.pattern()); -// } -// for (DbTableMeta tableMeta : dbTableMetaList) { -// Set<String> primaryKeySet = getPrimaryKeySet(metaData, tableMeta); -// doDbUniqueKeyMeta(metaData, tableMeta, primaryKeySet); -// doDbColumnMeta(metaData, tableMeta, primaryKeySet); -// doDbForeignKeyMeta(metaData, tableMeta); -// } -// if (readComment && !dialect.isJdbcCommentAvailable()) { -// readCommentFromDictinary(con, dbTableMetaList); -// } -// return dbTableMetaList; -// } finally { -// ConnectionUtil.close(con); -// } - } - - /** - * コメントをデータベースのディクショナリから直接取得します。 - * - * @param connection コネクション - * @param dbTableMetaList テーブルメタデータのリスト - */ - protected void readCommentFromDictinary(Connection connection, List<DbTableMeta> dbTableMetaList) { -// try { -// for (DbTableMeta tableMeta : dbTableMetaList) { -// String tableComment = -// dialect.getTableComment(connection, tableMeta.getCatalogName(), tableMeta.getSchemaName(), -// tableMeta.getName()); -// tableMeta.setComment(tableComment); -// Map<String, String> columnCommentMap = -// dialect.getColumnCommentMap(connection, tableMeta.getCatalogName(), tableMeta.getSchemaName(), -// tableMeta.getName()); -// for (DbColumnMeta columnMeta : tableMeta.getColumnMetaList()) { -// String columnName = columnMeta.getName(); -// if (columnCommentMap.containsKey(columnName)) { -// String columnComment = columnCommentMap.get(columnName); -// columnMeta.setComment(columnComment); -// } -// } -// } -// } catch (SQLException e) { -// throw new SQLRuntimeException(e); -// } - } -} +/* + * Copyright 2004-2009 the Seasar Foundation and the Others. + * + * 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.jiemamy.entity.io.gen.meta.impl; + +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.regex.Pattern; + +import javax.sql.DataSource; + +import org.jiemamy.entity.io.gen.dialect.GenDialect; +import org.jiemamy.entity.io.gen.meta.DbColumnMeta; +import org.jiemamy.entity.io.gen.meta.DbForeignKeyMeta; +import org.jiemamy.entity.io.gen.meta.DbTableMeta; +import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; +import org.jiemamy.entity.io.gen.meta.DbUniqueKeyMeta; + +/** + * {@code DbTableMetaReader}の実装クラスです。 + * + * @author taedium + */ +public class DbTableMetaReaderImpl implements DbTableMetaReader { + + /** ロガー */ + + /** データソース */ + protected DataSource dataSource; + + /** 方言 */ + protected GenDialect dialect; + + /** スキーマ名 */ + protected String schemaName; + + /** 読み取り対象とするテーブル名のパターン */ + protected Pattern tableNamePattern; + + /** 読み取り非対象とするテーブル名のパターン */ + protected Pattern ignoreTableNamePattern; + + /** コメントを読む場合{@code true} */ + protected boolean readComment; + + + /** + * インスタンスを構築します。 + * + * @param dataSource + * データソース + * @param dialect + * 方言 + * @param schemaName + * スキーマ名、デフォルトのスキーマ名を表す場合は{@code null} + * @param tableNamePattern + * 対象とするテーブル名の正規表現 + * @param ignoreTableNamePattern + * 対象としないテーブル名の正規表現 + * @param readComment + * コメントを読む場合{@code true} + */ + public DbTableMetaReaderImpl(DataSource dataSource, GenDialect dialect, String schemaName, String tableNamePattern, + String ignoreTableNamePattern, boolean readComment) { + if (dataSource == null) { + throw new NullPointerException("dataSource"); + } + if (dialect == null) { + throw new NullPointerException("dialect"); + } + if (tableNamePattern == null) { + throw new NullPointerException("tableNamePattern"); + } + if (ignoreTableNamePattern == null) { + throw new NullPointerException("ignoreTableNamePattern"); + } + this.dataSource = dataSource; + this.dialect = dialect; + this.schemaName = schemaName; + this.tableNamePattern = Pattern.compile(tableNamePattern, Pattern.CASE_INSENSITIVE); + this.ignoreTableNamePattern = Pattern.compile(ignoreTableNamePattern, Pattern.CASE_INSENSITIVE); + this.readComment = readComment; + } + + /** + * カラムメタデータを処理します。 + * + * @param metaData データベースメタデータ + * @param tableMeta テーブルメタデータ + * @param primaryKeySet 主キーのセット + */ + protected void doDbColumnMeta(DatabaseMetaData metaData, DbTableMeta tableMeta, Set<String> primaryKeySet) { + for (DbColumnMeta columnMeta : getDbColumnMetaList(metaData, tableMeta)) { + if (primaryKeySet.contains(columnMeta.getName())) { + columnMeta.setPrimaryKey(true); + if (primaryKeySet.size() == 1) { + columnMeta.setAutoIncrement(isAutoIncrement(metaData, tableMeta, columnMeta.getName())); + } + } + for (DbUniqueKeyMeta ukMeta : tableMeta.getUniqueKeyMetaList()) { + if (ukMeta.getColumnNameList().size() == 1) { + String ukColumnName = ukMeta.getColumnNameList().get(0); + if (columnMeta.getName().equals(ukColumnName)) { + columnMeta.setUnique(true); + } + } + } + tableMeta.addColumnMeta(columnMeta); + } + } + + /** + * 外部キーメタデータを処理する。 + * + * @param metaData データベースメタデータ + * @param tableMeta テーブルメタデータ + */ + protected void doDbForeignKeyMeta(DatabaseMetaData metaData, DbTableMeta tableMeta) { + for (DbForeignKeyMeta fkMeta : getDbForeignKeyMetaList(metaData, tableMeta)) { + for (DbUniqueKeyMeta ukMeta : tableMeta.getUniqueKeyMetaList()) { + if (fkMeta.getForeignKeyColumnNameList().equals(ukMeta.getColumnNameList())) { + fkMeta.setUnique(true); + } + } + tableMeta.addForeignKeyMeta(fkMeta); + } + } + + /** + * 一意キーメタデータを処理します。 + * + * @param metaData データベースメタデータ + * @param tableMeta テーブルメタデータ + * @param primaryKeySet 主キーのセット + */ + protected void doDbUniqueKeyMeta(DatabaseMetaData metaData, DbTableMeta tableMeta, Set<String> primaryKeySet) { + for (DbUniqueKeyMeta ukMeta : getDbUniqueKeyMetaList(metaData, tableMeta)) { + if (primaryKeySet.size() == ukMeta.getColumnNameList().size() + && primaryKeySet.containsAll(ukMeta.getColumnNameList())) { + ukMeta.setPrimaryKey(true); + } + tableMeta.addUniqueKeyMeta(ukMeta); + } + } + + /** + * カラムメタデータのリストを取得する。 + * + * @param metaData データベースメタデータ + * @param tableMeta テーブルメタデータ + * + * @return カラムメタデータのリスト + */ + protected List<DbColumnMeta> getDbColumnMetaList(DatabaseMetaData metaData, DbTableMeta tableMeta) { + List<DbColumnMeta> result = new ArrayList<DbColumnMeta>(); +// try { +// ResultSet rs = +// metaData.getColumns(tableMeta.getCatalogName(), tableMeta.getSchemaName(), tableMeta.getName(), +// null); +// try { +// while (rs.next()) { +// DbColumnMeta columnDesc = new DbColumnMeta(); +// columnDesc.setName(rs.getString("COLUMN_NAME")); +// columnDesc.setSqlType(rs.getInt("DATA_TYPE")); +// columnDesc.setTypeName(rs.getString("TYPE_NAME")); +// columnDesc.setLength(rs.getInt("COLUMN_SIZE")); +// columnDesc.setScale(rs.getInt("DECIMAL_DIGITS")); +// columnDesc.setNullable(rs.getBoolean("NULLABLE")); +// columnDesc.setDefaultValue(rs.getString("COLUMN_DEF")); +// if (readComment) { +// columnDesc.setComment(rs.getString("REMARKS")); +// } +// result.add(columnDesc); +// } +// return result; +// } finally { +// ResultSetUtil.close(rs); +// } +// } catch (SQLException ex) { +// throw new SQLRuntimeException(ex); +// } + return result; + } + + /** + * 外部キーメタデータのリストを返します。 + * + * @param metaData データベースメタデータ + * @param tableMeta テーブルメタデータ + * @return 外部キーメタデータのリスト + */ + protected List<DbForeignKeyMeta> getDbForeignKeyMetaList(DatabaseMetaData metaData, DbTableMeta tableMeta) { + return null; +// @SuppressWarnings("unchecked") +// Map<String, DbForeignKeyMeta> map = new ArrayMap(); +// try { +// ResultSet rs = +// metaData +// .getImportedKeys(tableMeta.getCatalogName(), tableMeta.getSchemaName(), tableMeta.getName()); +// try { +// while (rs.next()) { +// String name = rs.getString("FK_NAME"); +// if (!map.containsKey(name)) { +// DbForeignKeyMeta fkMeta = new DbForeignKeyMeta(); +// fkMeta.setName(name); +// fkMeta.setPrimaryKeyCatalogName(rs.getString("PKTABLE_CAT")); +// fkMeta.setPrimaryKeySchemaName(rs.getString("PKTABLE_SCHEM")); +// fkMeta.setPrimaryKeyTableName(rs.getString("PKTABLE_NAME")); +// map.put(name, fkMeta); +// } +// DbForeignKeyMeta fkMeta = map.get(name); +// fkMeta.addPrimaryKeyColumnName(rs.getString("PKCOLUMN_NAME")); +// fkMeta.addForeignKeyColumnName(rs.getString("FKCOLUMN_NAME")); +// } +// } finally { +// ResultSetUtil.close(rs); +// } +// DbForeignKeyMeta[] array = map.values().toArray(new DbForeignKeyMeta[map.size()]); +// return Arrays.asList(array); +// } catch (SQLException ex) { +// throw new SQLRuntimeException(ex); +// } + } + + /** + * テーブルメタデータのリストを返します。 + * + * @param metaData データベースメタデータ + * @param schemaName スキーマ名 + * @return テーブルメタデータのリスト + */ + protected List<DbTableMeta> getDbTableMetaList(DatabaseMetaData metaData, String schemaName) { + List<DbTableMeta> result = new ArrayList<DbTableMeta>(); +// try { +// ResultSet rs = metaData.getTables(null, schemaName, null, new String[] { +// "TABLE" +// }); +// try { +// while (rs.next()) { +// DbTableMeta dbTableMeta = new DbTableMeta(); +// dbTableMeta.setCatalogName(rs.getString("TABLE_CAT")); +// dbTableMeta.setSchemaName(rs.getString("TABLE_SCHEM")); +// dbTableMeta.setName(rs.getString("TABLE_NAME")); +// if (readComment) { +// dbTableMeta.setComment(rs.getString("REMARKS")); +// } +// if (isTargetTable(dbTableMeta)) { +// result.add(dbTableMeta); +// } +// } +// return result; +// } finally { +// ResultSetUtil.close(rs); +// } +// } catch (SQLException e) { +// throw new SQLRuntimeException(e); +// } + return result; + } + + /** + * 一意キーメタデータのリストを返します。 + * + * @param metaData データベースメタデータ + * @param tableMeta テーブルメタデータ + * @return 一意キーメタデータのリスト + */ + protected List<DbUniqueKeyMeta> getDbUniqueKeyMetaList(DatabaseMetaData metaData, DbTableMeta tableMeta) { + return null; +// if (!dialect.supportsGetIndexInfo(tableMeta.getCatalogName(), tableMeta.getSchemaName(), tableMeta.getName())) { +// logger.log("WS2JDBCGen0002", new Object[] { +// tableMeta.getCatalogName(), +// tableMeta.getSchemaName(), +// tableMeta.getName() +// }); +// return Collections.emptyList(); +// } +// +// @SuppressWarnings("unchecked") +// Map<String, DbUniqueKeyMeta> map = new ArrayMap(); +// try { +// ResultSet rs = +// metaData.getIndexInfo(tableMeta.getCatalogName(), tableMeta.getSchemaName(), tableMeta.getName(), +// true, false); +// try { +// while (rs.next()) { +// String name = rs.getString("INDEX_NAME"); +// if (!map.containsKey(name)) { +// DbUniqueKeyMeta ukMeta = new DbUniqueKeyMeta(); +// ukMeta.setName(name); +// map.put(name, ukMeta); +// } +// DbUniqueKeyMeta ukMeta = map.get(name); +// ukMeta.addColumnName(rs.getString("COLUMN_NAME")); +// } +// } finally { +// ResultSetUtil.close(rs); +// } +// DbUniqueKeyMeta[] array = map.values().toArray(new DbUniqueKeyMeta[map.size()]); +// return Arrays.asList(array); +// } catch (SQLException ex) { +// throw new SQLRuntimeException(ex); +// } + } + + /** + * デフォルトのスキーマ名を返します。 + * + * @param metaData データベースメタデータ + * @return デフォルトのスキーマ名 + */ + protected String getDefaultSchemaName(DatabaseMetaData metaData) { +// String userName = DatabaseMetaDataUtil.getUserName(metaData); +// return dialect.getDefaultSchemaName(userName); + return null; + } + + /** + * 主キーのセットを返します。 + * + * @param metaData データベースメタデータ + * @param tableMeta + * テーブルメタデータ + * @return 主キーのセット + */ + protected Set<String> getPrimaryKeySet(DatabaseMetaData metaData, DbTableMeta tableMeta) { + Set<String> result = new HashSet<String>(); +// try { +// ResultSet rs = +// metaData.getPrimaryKeys(tableMeta.getCatalogName(), tableMeta.getSchemaName(), tableMeta.getName()); +// try { +// while (rs.next()) { +// result.add(rs.getString("COLUMN_NAME")); +// } +// } finally { +// ResultSetUtil.close(rs); +// } +// return result; +// } catch (SQLException ex) { +// throw new SQLRuntimeException(ex); +// } + return result; + } + + /** + * 列の値が自動的に増分される場合{@code true}を返します。 + * + * @param metaData データベースメタデータ + * @param tableMeta テーブルメタデータ + * @param columnName カラム名 + * @return 列が自動的に増分される場合{@code true}、そうでない場合{@code false} + */ + protected boolean isAutoIncrement(DatabaseMetaData metaData, DbTableMeta tableMeta, String columnName) { +// try { +// return dialect.isAutoIncrement(metaData.getConnection(), tableMeta.getCatalogName(), tableMeta +// .getSchemaName(), tableMeta.getName(), columnName); +// } catch (SQLException ex) { +// throw new SQLRuntimeException(ex); +// } + return false; + } + + /** + * 読み取り対象のテーブルの場合{@code true}を返します。 + * + * @param dbTableMeta テーブルメタデータ + * @return 読み取り対象のテーブルの場合{@code true} + */ + protected boolean isTargetTable(DbTableMeta dbTableMeta) { + String name = dbTableMeta.getName(); + if (!tableNamePattern.matcher(name).matches()) { + return false; + } + if (ignoreTableNamePattern.matcher(name).matches()) { + return false; + } + return true; + } + + public List<DbTableMeta> read() { + return null; +// Connection con = DataSourceUtil.getConnection(dataSource); +// try { +// DatabaseMetaData metaData = ConnectionUtil.getMetaData(con); +// List<DbTableMeta> dbTableMetaList = +// getDbTableMetaList(metaData, schemaName != null ? schemaName : getDefaultSchemaName(metaData)); +// if (dbTableMetaList.isEmpty()) { +// throw new TableNotFoundRuntimeException(dialect.getClass().getName(), schemaName, tableNamePattern +// .pattern(), ignoreTableNamePattern.pattern()); +// } +// for (DbTableMeta tableMeta : dbTableMetaList) { +// Set<String> primaryKeySet = getPrimaryKeySet(metaData, tableMeta); +// doDbUniqueKeyMeta(metaData, tableMeta, primaryKeySet); +// doDbColumnMeta(metaData, tableMeta, primaryKeySet); +// doDbForeignKeyMeta(metaData, tableMeta); +// } +// if (readComment && !dialect.isJdbcCommentAvailable()) { +// readCommentFromDictinary(con, dbTableMetaList); +// } +// return dbTableMetaList; +// } finally { +// ConnectionUtil.close(con); +// } + } + + /** + * コメントをデータベースのディクショナリから直接取得します。 + * + * @param connection コネクション + * @param dbTableMetaList テーブルメタデータのリスト + */ + protected void readCommentFromDictinary(Connection connection, List<DbTableMeta> dbTableMetaList) { +// try { +// for (DbTableMeta tableMeta : dbTableMetaList) { +// String tableComment = +// dialect.getTableComment(connection, tableMeta.getCatalogName(), tableMeta.getSchemaName(), +// tableMeta.getName()); +// tableMeta.setComment(tableComment); +// Map<String, String> columnCommentMap = +// dialect.getColumnCommentMap(connection, tableMeta.getCatalogName(), tableMeta.getSchemaName(), +// tableMeta.getName()); +// for (DbColumnMeta columnMeta : tableMeta.getColumnMetaList()) { +// String columnName = columnMeta.getName(); +// if (columnCommentMap.containsKey(columnName)) { +// String columnComment = columnCommentMap.get(columnName); +// columnMeta.setComment(columnComment); +// } +// } +// } +// } catch (SQLException e) { +// throw new SQLRuntimeException(e); +// } + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/meta/impl/DbTableMetaReaderImpl.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AssociationModel.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AssociationModel.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AssociationModel.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,163 +1,163 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model; - -import org.jiemamy.entity.io.gen.desc.AssociationType; - -/** - * 関連モデル。 - * - * @author j5ik2o - */ -public class AssociationModel { - - /** 名前 */ - protected String name; - - /** クラスの単純名 */ - protected String shortClassName; - - /** 関連タイプ */ - protected AssociationType associationType; - - /** 関連の所有者側のプロパティの名前 */ - protected String mappedBy; - - /** 結合カラムモデル */ - protected JoinColumnModel joinColumnModel; - - /** 複合結合カラムモデル */ - protected JoinColumnsModel joinColumnsModel; - - - /** - * 関連タイプを取得する。 - * - * @return 関連タイプ - */ - public AssociationType getAssociationType() { - return associationType; - } - - /** - * 結合カラムモデルを取得する。 - * - * @return 結合カラムモデル - */ - public JoinColumnModel getJoinColumnModel() { - return joinColumnModel; - } - - /** - * 複合結合カラムモデルを取得する。 - * - * @return 複合結合カラムモデル - */ - public JoinColumnsModel getJoinColumnsModel() { - return joinColumnsModel; - } - - /** - * 関連の所有者側のプロパティの名前を取得する。 - * - * @return 関連の所有者側のプロパティの名前 - */ - public String getMappedBy() { - return mappedBy; - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return name; - } - - /** - * クラスの単純名を取得する。 - * - * @return クラスの単純名 - */ - public String getShortClassName() { - return shortClassName; - } - - /** - * 関連タイプを設定する。 - * - * @param associationType 関連タイプ - */ - public void setAssociationType(AssociationType associationType) { - this.associationType = associationType; - } - - /** - * 結合カラムモデルを設定する。 - * - * @param joinColumnModel 結合カラムモデル - * - */ - public void setJoinColumnModel(JoinColumnModel joinColumnModel) { - if (joinColumnsModel != null) { - throw new IllegalStateException("joinColumnsModel"); - } - this.joinColumnModel = joinColumnModel; - } - - /** - * 複合結合カラムモデルを設定する。 - * - * @param joinColumnsModel 複合結合カラムモデル - */ - public void setJoinColumnsModel(JoinColumnsModel joinColumnsModel) { - if (joinColumnModel != null) { - throw new IllegalStateException("joinColumnModel"); - } - this.joinColumnsModel = joinColumnsModel; - } - - /** - * 関連の所有者側のプロパティの名前を設定する。 - * - * @param mappedBy 関連の所有者側のプロパティの名前 - */ - public void setMappedBy(String mappedBy) { - this.mappedBy = mappedBy; - } - - /** - * 名前を設定する。 - * - * @param name 名前 - */ - public void setName(String name) { - this.name = name; - } - - /** - * クラスの単純名を設定する。 - * - * @param shortClassName クラスの単純名 - */ - public void setShortClassName(String shortClassName) { - this.shortClassName = shortClassName; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model; + +import org.jiemamy.entity.io.gen.desc.AssociationType; + +/** + * 関連モデル。 + * + * @author j5ik2o + */ +public class AssociationModel { + + /** 名前 */ + protected String name; + + /** クラスの単純名 */ + protected String shortClassName; + + /** 関連タイプ */ + protected AssociationType associationType; + + /** 関連の所有者側のプロパティの名前 */ + protected String mappedBy; + + /** 結合カラムモデル */ + protected JoinColumnModel joinColumnModel; + + /** 複合結合カラムモデル */ + protected JoinColumnsModel joinColumnsModel; + + + /** + * 関連タイプを取得する。 + * + * @return 関連タイプ + */ + public AssociationType getAssociationType() { + return associationType; + } + + /** + * 結合カラムモデルを取得する。 + * + * @return 結合カラムモデル + */ + public JoinColumnModel getJoinColumnModel() { + return joinColumnModel; + } + + /** + * 複合結合カラムモデルを取得する。 + * + * @return 複合結合カラムモデル + */ + public JoinColumnsModel getJoinColumnsModel() { + return joinColumnsModel; + } + + /** + * 関連の所有者側のプロパティの名前を取得する。 + * + * @return 関連の所有者側のプロパティの名前 + */ + public String getMappedBy() { + return mappedBy; + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return name; + } + + /** + * クラスの単純名を取得する。 + * + * @return クラスの単純名 + */ + public String getShortClassName() { + return shortClassName; + } + + /** + * 関連タイプを設定する。 + * + * @param associationType 関連タイプ + */ + public void setAssociationType(AssociationType associationType) { + this.associationType = associationType; + } + + /** + * 結合カラムモデルを設定する。 + * + * @param joinColumnModel 結合カラムモデル + * + */ + public void setJoinColumnModel(JoinColumnModel joinColumnModel) { + if (joinColumnsModel != null) { + throw new IllegalStateException("joinColumnsModel"); + } + this.joinColumnModel = joinColumnModel; + } + + /** + * 複合結合カラムモデルを設定する。 + * + * @param joinColumnsModel 複合結合カラムモデル + */ + public void setJoinColumnsModel(JoinColumnsModel joinColumnsModel) { + if (joinColumnModel != null) { + throw new IllegalStateException("joinColumnModel"); + } + this.joinColumnsModel = joinColumnsModel; + } + + /** + * 関連の所有者側のプロパティの名前を設定する。 + * + * @param mappedBy 関連の所有者側のプロパティの名前 + */ + public void setMappedBy(String mappedBy) { + this.mappedBy = mappedBy; + } + + /** + * 名前を設定する。 + * + * @param name 名前 + */ + public void setName(String name) { + this.name = name; + } + + /** + * クラスの単純名を設定する。 + * + * @param shortClassName クラスの単純名 + */ + public void setShortClassName(String shortClassName) { + this.shortClassName = shortClassName; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AssociationModel.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AssociationModelFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AssociationModelFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AssociationModelFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,36 +1,36 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model; - -import org.jiemamy.entity.io.gen.desc.AssociationDesc; - -/** - * {@link AssociationModel}のファクトリインターフェイス。 - * - * @author j5ik2o - */ -public interface AssociationModelFactory { - - /** - * 関連モデルを取得する。 - * - * @param associationDesc 関連記述 - * @return 関連モデル - */ - AssociationModel getAssociationModel(AssociationDesc associationDesc); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model; + +import org.jiemamy.entity.io.gen.desc.AssociationDesc; + +/** + * {@link AssociationModel}のファクトリインターフェイス。 + * + * @author j5ik2o + */ +public interface AssociationModelFactory { + + /** + * 関連モデルを取得する。 + * + * @param associationDesc 関連記述 + * @return 関連モデル + */ + AssociationModel getAssociationModel(AssociationDesc associationDesc); +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AssociationModelFactory.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AttributeModel.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AttributeModel.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AttributeModel.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,450 +1,450 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model; - -import javax.persistence.GenerationType; -import javax.persistence.TemporalType; - -/** - * エンティティの属性モデル。 - * - * @author j5ik2o - */ -public class AttributeModel { - - /** 名前 */ - protected String name; - - /** 属性のクラス */ - protected Class<?> attributeClass; - - /** 識別子の場合{@code true} */ - protected boolean id; - - /** 識別子の生成方法を示す列挙型、生成しない場合{@code null} */ - protected GenerationType generationType; - - /** 識別子の初期値 */ - protected int initialValue; - - /** 識別子の割り当てサイズ */ - protected int allocationSize; - - /** 時制の種別 */ - protected TemporalType temporalType; - - /** バージョンの場合{@code true} */ - protected boolean version; - - /** 一時的の場合{@code true} */ - protected boolean trnsient; - - /** {@code LOB}の場合{@code true} */ - protected boolean lob; - - /** NULL可能の場合{@code true} */ - protected boolean nullable; - - /** 一意の場合{@code true}、そうでない場合{@code false} */ - protected boolean unique; - - /** 長さ */ - protected Integer length; - - /** 精度 */ - protected Integer precision; - - /** スケール */ - protected Integer scale; - - /** カラム名 */ - protected String columnName; - - /** カラム定義 */ - protected String columnDefinition; - - /** カラムの型名 */ - protected String columnTypeName; - - /** サポートされていないカラム型の場合{@code true} */ - protected boolean unsupportedColumnType; - - /** コメント */ - protected String comment; - - - /** - * 識別子の割り当てサイズを取得する。 - * - * @return 識別子の割り当てサイズ - */ - public int getAllocationSize() { - return allocationSize; - } - - /** - * 属性のクラスを取得する。 - * - * @return 属性のクラス - */ - public Class<?> getAttributeClass() { - return attributeClass; - } - - /** - * カラム定義を取得する。 - * - * @return カラム定義 - */ - public String getColumnDefinition() { - return columnDefinition; - } - - /** - * カラム名を取得する。 - * - * @return カラム名 - */ - public String getColumnName() { - return columnName; - } - - /** - * カラムの型名を取得する。 - * - * @return カラムの型名 - */ - public String getColumnTypeName() { - return columnTypeName; - } - - /** - * コメントを取得する。 - * - * @return コメント - */ - public String getComment() { - return comment; - } - - /** - * 識別子の生成方法を示す列挙型を取得する。 - * - * @return 識別子の生成方法を示す列挙型、生成しない場合{@code null} - */ - public GenerationType getGenerationType() { - return generationType; - } - - /** - * 識別子の初期値を取得する。 - * - * @return 識別子の初期値 - */ - public int getInitialValue() { - return initialValue; - } - - /** - * 長さを取得する。 - * - * @return 長さ - */ - public Integer getLength() { - return length; - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return name; - } - - /** - * 精度を取得する。 - * - * @return 精度 - */ - public Integer getPrecision() { - return precision; - } - - /** - * スケールを取得する。 - * - * @return スケール - */ - public Integer getScale() { - return scale; - } - - /** - * 時制の種別を取得する。 - * - * @return 時制の種別 - */ - public TemporalType getTemporalType() { - return temporalType; - } - - /** - * 識別子を取得する。 - * - * @return 識別子 - */ - public boolean isId() { - return id; - } - - /** - * {@code LOB}の場合{@code true}を取得する。 - * - * @return {@code LOB}の場合{@code true} - */ - public boolean isLob() { - return lob; - } - - /** - * NULL可能の場合{@code true}を取得する。 - * - * @return NULL可能の場合{@code true} - */ - public boolean isNullable() { - return nullable; - } - - /** - * 一時的の場合{@code true}を取得する。 - * - * @return 一時的の場合{@code true} - */ - public boolean isTransient() { - return trnsient; - } - - /** - * 一意の場合{@code true}、そうでない場合{@code false}を取得する。 - * - * @return 一意の場合{@code true}、そうでない場合{@code false} - */ - public boolean isUnique() { - return unique; - } - - /** - * サポートされていないカラム型の場合{@code true}を取得する。 - * - * @return サポートされていないカラム型の場合{@code true}、そうでない場合{@code false} - */ - public boolean isUnsupportedColumnType() { - return unsupportedColumnType; - } - - /** - * バージョンの場合{@code true}を取得する。 - * - * @return バージョンの場合{@code true} - */ - public boolean isVersion() { - return version; - } - - /** - * 識別子の割り当てサイズを設定する。 - * - * @param allocationSize 識別子の割り当てサイズ - */ - public void setAllocationSize(int allocationSize) { - this.allocationSize = allocationSize; - } - - /** - * 属性のクラスを設定する。 - * - * @param attributeClass 属性のクラス - */ - public void setAttributeClass(Class<?> attributeClass) { - this.attributeClass = attributeClass; - } - - /** - * カラム定義を設定する。 - * - * @param columnDefinition カラム定義 - */ - public void setColumnDefinition(String columnDefinition) { - this.columnDefinition = columnDefinition; - } - - /** - * カラム名を設定する。 - * - * @param columnName カラム名 - */ - public void setColumnName(String columnName) { - this.columnName = columnName; - } - - /** - * カラムの型名を設定する。 - * - * @param columnTypeName カラムの型名 - */ - public void setColumnTypeName(String columnTypeName) { - this.columnTypeName = columnTypeName; - } - - /** - * コメントを設定する。 - * - * @param comment コメント - */ - public void setComment(String comment) { - this.comment = comment; - } - - /** - * 識別子の生成方法を示す列挙型を設定する。 - * - * @param generationType 識別子の生成方法を示す列挙型、生成しない場合{@code null} - */ - public void setGenerationType(GenerationType generationType) { - this.generationType = generationType; - } - - /** - * 識別子を設定する。 - * - * @param id 識別子 - */ - public void setId(boolean id) { - this.id = id; - } - - /** - * 識別子の初期値を設定する。 - * - * @param initialValue 識別子の初期値 - */ - public void setInitialValue(int initialValue) { - this.initialValue = initialValue; - } - - /** - * 長さを設定する。 - * - * @param length 長さ - */ - public void setLength(Integer length) { - this.length = length; - } - - /** - * {@code LOB}の場合{@code true}を設定する。 - * - * @param lob {@code LOB}の場合{@code true} - */ - public void setLob(boolean lob) { - this.lob = lob; - } - - /** - * 名前を設定する。 - * - * @param name 名前 - */ - public void setName(String name) { - this.name = name; - } - - /** - * NULL可能の場合{@code true}を設定する。 - * - * @param nullable NULL可能の場合{@code true} - */ - public void setNullable(boolean nullable) { - this.nullable = nullable; - } - - /** - * 精度を設定する。 - * - * @param precision 精度 - */ - public void setPrecision(Integer precision) { - this.precision = precision; - } - - /** - * スケールを設定する。 - * - * @param scale スケール - */ - public void setScale(Integer scale) { - this.scale = scale; - } - - /** - * 時制の種別を設定する。 - * - * @param temporalType 時制の種別 - */ - public void setTemporalType(TemporalType temporalType) { - this.temporalType = temporalType; - } - - /** - * 一時的の場合{@code true}を設定する。 - * - * @param trnsient 一時的の場合{@code true} - */ - public void setTransient(boolean trnsient) { - this.trnsient = trnsient; - } - - /** - * 一意の場合{@code true}、そうでない場合{@code false}を設定する。 - * - * @param unique 一意の場合{@code true} - */ - public void setUnique(boolean unique) { - this.unique = unique; - } - - /** - * サポートされていないカラム型の場合{@code true}を設定する。 - * - * @param unsupportedColumnType サポートされていないカラム型の場合{@code true}、そうでない場合{@code false} - */ - public void setUnsupportedColumnType(boolean unsupportedColumnType) { - this.unsupportedColumnType = unsupportedColumnType; - } - - /** - * バージョンの場合{@code true}を設定する。 - * - * @param version バージョンの場合{@code true} - */ - public void setVersion(boolean version) { - this.version = version; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model; + +import javax.persistence.GenerationType; +import javax.persistence.TemporalType; + +/** + * エンティティの属性モデル。 + * + * @author j5ik2o + */ +public class AttributeModel { + + /** 名前 */ + protected String name; + + /** 属性のクラス */ + protected Class<?> attributeClass; + + /** 識別子の場合{@code true} */ + protected boolean id; + + /** 識別子の生成方法を示す列挙型、生成しない場合{@code null} */ + protected GenerationType generationType; + + /** 識別子の初期値 */ + protected int initialValue; + + /** 識別子の割り当てサイズ */ + protected int allocationSize; + + /** 時制の種別 */ + protected TemporalType temporalType; + + /** バージョンの場合{@code true} */ + protected boolean version; + + /** 一時的の場合{@code true} */ + protected boolean trnsient; + + /** {@code LOB}の場合{@code true} */ + protected boolean lob; + + /** NULL可能の場合{@code true} */ + protected boolean nullable; + + /** 一意の場合{@code true}、そうでない場合{@code false} */ + protected boolean unique; + + /** 長さ */ + protected Integer length; + + /** 精度 */ + protected Integer precision; + + /** スケール */ + protected Integer scale; + + /** カラム名 */ + protected String columnName; + + /** カラム定義 */ + protected String columnDefinition; + + /** カラムの型名 */ + protected String columnTypeName; + + /** サポートされていないカラム型の場合{@code true} */ + protected boolean unsupportedColumnType; + + /** コメント */ + protected String comment; + + + /** + * 識別子の割り当てサイズを取得する。 + * + * @return 識別子の割り当てサイズ + */ + public int getAllocationSize() { + return allocationSize; + } + + /** + * 属性のクラスを取得する。 + * + * @return 属性のクラス + */ + public Class<?> getAttributeClass() { + return attributeClass; + } + + /** + * カラム定義を取得する。 + * + * @return カラム定義 + */ + public String getColumnDefinition() { + return columnDefinition; + } + + /** + * カラム名を取得する。 + * + * @return カラム名 + */ + public String getColumnName() { + return columnName; + } + + /** + * カラムの型名を取得する。 + * + * @return カラムの型名 + */ + public String getColumnTypeName() { + return columnTypeName; + } + + /** + * コメントを取得する。 + * + * @return コメント + */ + public String getComment() { + return comment; + } + + /** + * 識別子の生成方法を示す列挙型を取得する。 + * + * @return 識別子の生成方法を示す列挙型、生成しない場合{@code null} + */ + public GenerationType getGenerationType() { + return generationType; + } + + /** + * 識別子の初期値を取得する。 + * + * @return 識別子の初期値 + */ + public int getInitialValue() { + return initialValue; + } + + /** + * 長さを取得する。 + * + * @return 長さ + */ + public Integer getLength() { + return length; + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return name; + } + + /** + * 精度を取得する。 + * + * @return 精度 + */ + public Integer getPrecision() { + return precision; + } + + /** + * スケールを取得する。 + * + * @return スケール + */ + public Integer getScale() { + return scale; + } + + /** + * 時制の種別を取得する。 + * + * @return 時制の種別 + */ + public TemporalType getTemporalType() { + return temporalType; + } + + /** + * 識別子を取得する。 + * + * @return 識別子 + */ + public boolean isId() { + return id; + } + + /** + * {@code LOB}の場合{@code true}を取得する。 + * + * @return {@code LOB}の場合{@code true} + */ + public boolean isLob() { + return lob; + } + + /** + * NULL可能の場合{@code true}を取得する。 + * + * @return NULL可能の場合{@code true} + */ + public boolean isNullable() { + return nullable; + } + + /** + * 一時的の場合{@code true}を取得する。 + * + * @return 一時的の場合{@code true} + */ + public boolean isTransient() { + return trnsient; + } + + /** + * 一意の場合{@code true}、そうでない場合{@code false}を取得する。 + * + * @return 一意の場合{@code true}、そうでない場合{@code false} + */ + public boolean isUnique() { + return unique; + } + + /** + * サポートされていないカラム型の場合{@code true}を取得する。 + * + * @return サポートされていないカラム型の場合{@code true}、そうでない場合{@code false} + */ + public boolean isUnsupportedColumnType() { + return unsupportedColumnType; + } + + /** + * バージョンの場合{@code true}を取得する。 + * + * @return バージョンの場合{@code true} + */ + public boolean isVersion() { + return version; + } + + /** + * 識別子の割り当てサイズを設定する。 + * + * @param allocationSize 識別子の割り当てサイズ + */ + public void setAllocationSize(int allocationSize) { + this.allocationSize = allocationSize; + } + + /** + * 属性のクラスを設定する。 + * + * @param attributeClass 属性のクラス + */ + public void setAttributeClass(Class<?> attributeClass) { + this.attributeClass = attributeClass; + } + + /** + * カラム定義を設定する。 + * + * @param columnDefinition カラム定義 + */ + public void setColumnDefinition(String columnDefinition) { + this.columnDefinition = columnDefinition; + } + + /** + * カラム名を設定する。 + * + * @param columnName カラム名 + */ + public void setColumnName(String columnName) { + this.columnName = columnName; + } + + /** + * カラムの型名を設定する。 + * + * @param columnTypeName カラムの型名 + */ + public void setColumnTypeName(String columnTypeName) { + this.columnTypeName = columnTypeName; + } + + /** + * コメントを設定する。 + * + * @param comment コメント + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** + * 識別子の生成方法を示す列挙型を設定する。 + * + * @param generationType 識別子の生成方法を示す列挙型、生成しない場合{@code null} + */ + public void setGenerationType(GenerationType generationType) { + this.generationType = generationType; + } + + /** + * 識別子を設定する。 + * + * @param id 識別子 + */ + public void setId(boolean id) { + this.id = id; + } + + /** + * 識別子の初期値を設定する。 + * + * @param initialValue 識別子の初期値 + */ + public void setInitialValue(int initialValue) { + this.initialValue = initialValue; + } + + /** + * 長さを設定する。 + * + * @param length 長さ + */ + public void setLength(Integer length) { + this.length = length; + } + + /** + * {@code LOB}の場合{@code true}を設定する。 + * + * @param lob {@code LOB}の場合{@code true} + */ + public void setLob(boolean lob) { + this.lob = lob; + } + + /** + * 名前を設定する。 + * + * @param name 名前 + */ + public void setName(String name) { + this.name = name; + } + + /** + * NULL可能の場合{@code true}を設定する。 + * + * @param nullable NULL可能の場合{@code true} + */ + public void setNullable(boolean nullable) { + this.nullable = nullable; + } + + /** + * 精度を設定する。 + * + * @param precision 精度 + */ + public void setPrecision(Integer precision) { + this.precision = precision; + } + + /** + * スケールを設定する。 + * + * @param scale スケール + */ + public void setScale(Integer scale) { + this.scale = scale; + } + + /** + * 時制の種別を設定する。 + * + * @param temporalType 時制の種別 + */ + public void setTemporalType(TemporalType temporalType) { + this.temporalType = temporalType; + } + + /** + * 一時的の場合{@code true}を設定する。 + * + * @param trnsient 一時的の場合{@code true} + */ + public void setTransient(boolean trnsient) { + this.trnsient = trnsient; + } + + /** + * 一意の場合{@code true}、そうでない場合{@code false}を設定する。 + * + * @param unique 一意の場合{@code true} + */ + public void setUnique(boolean unique) { + this.unique = unique; + } + + /** + * サポートされていないカラム型の場合{@code true}を設定する。 + * + * @param unsupportedColumnType サポートされていないカラム型の場合{@code true}、そうでない場合{@code false} + */ + public void setUnsupportedColumnType(boolean unsupportedColumnType) { + this.unsupportedColumnType = unsupportedColumnType; + } + + /** + * バージョンの場合{@code true}を設定する。 + * + * @param version バージョンの場合{@code true} + */ + public void setVersion(boolean version) { + this.version = version; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AttributeModel.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AttributeModelFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AttributeModelFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AttributeModelFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,37 +1,37 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model; - -import org.jiemamy.entity.io.gen.desc.AttributeDesc; - -/** - * {@link AttributeModel 属性モデル}のファクトリインターフェイス。 - * - * @author j5ik2o - */ -public interface AttributeModelFactory { - - /** - * 属性モデルを取得する。 - * - * @param attributeDesc 属性記述 - * @return 属性モデル - */ - AttributeModel getAttributeModel(AttributeDesc attributeDesc); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model; + +import org.jiemamy.entity.io.gen.desc.AttributeDesc; + +/** + * {@link AttributeModel 属性モデル}のファクトリインターフェイス。 + * + * @author j5ik2o + */ +public interface AttributeModelFactory { + + /** + * 属性モデルを取得する。 + * + * @param attributeDesc 属性記述 + * @return 属性モデル + */ + AttributeModel getAttributeModel(AttributeDesc attributeDesc); +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/AttributeModelFactory.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/ClassModel.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/ClassModel.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/ClassModel.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,116 +1,116 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model; - -import java.util.Collections; -import java.util.SortedSet; -import java.util.TreeSet; - -/** - * クラスのモデル。 - * - * @author j5ik2o - */ -public abstract class ClassModel extends GeneratedModel { - - /** インポート名のソートされたセット */ - protected SortedSet<String> importNameSet = new TreeSet<String>(); - - /** staticインポート名のソートされたセット */ - protected SortedSet<String> staticImportNameSet = new TreeSet<String>(); - - /** パッケージ名 */ - protected String packageName; - - /** クラスの単純名 */ - protected String shortClassName; - - - /** - * インポート名を追加する。 - * - * @param name インポート名 - */ - public void addImportName(String name) { - importNameSet.add(name); - } - - /** - * staticインポート名を追加する。 - * - * @param name staticインポート名 - */ - public void addStaticImportName(String name) { - staticImportNameSet.add(name); - } - - /** - * インポート名のソートされたセットを取得する。 - * - * @return インポート名のソートされたセット - */ - public SortedSet<String> getImportNameSet() { - return Collections.unmodifiableSortedSet(importNameSet); - } - - /** - * パッケージ名を取得する。 - * - * @return パッケージ名 - */ - public String getPackageName() { - return packageName; - } - - /** - * クラスの単純名を取得する。 - * - * @return クラスの単純名 - */ - public String getShortClassName() { - return shortClassName; - } - - /** - * staticインポート名のソートされたセットを取得する。 - * - * @return staticインポート名のソートされたセット - */ - public SortedSet<String> getStaticImportNameSet() { - return Collections.unmodifiableSortedSet(staticImportNameSet); - } - - /** - * パッケージ名を設定する。 - * - * @param packageName パッケージ名 - */ - public void setPackageName(String packageName) { - this.packageName = packageName; - } - - /** - * クラスの単純名を設定する。 - * - * @param shortClassName クラスの単純名 - */ - public void setShortClassName(String shortClassName) { - this.shortClassName = shortClassName; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model; + +import java.util.Collections; +import java.util.SortedSet; +import java.util.TreeSet; + +/** + * クラスのモデル。 + * + * @author j5ik2o + */ +public abstract class ClassModel extends GeneratedModel { + + /** インポート名のソートされたセット */ + protected SortedSet<String> importNameSet = new TreeSet<String>(); + + /** staticインポート名のソートされたセット */ + protected SortedSet<String> staticImportNameSet = new TreeSet<String>(); + + /** パッケージ名 */ + protected String packageName; + + /** クラスの単純名 */ + protected String shortClassName; + + + /** + * インポート名を追加する。 + * + * @param name インポート名 + */ + public void addImportName(String name) { + importNameSet.add(name); + } + + /** + * staticインポート名を追加する。 + * + * @param name staticインポート名 + */ + public void addStaticImportName(String name) { + staticImportNameSet.add(name); + } + + /** + * インポート名のソートされたセットを取得する。 + * + * @return インポート名のソートされたセット + */ + public SortedSet<String> getImportNameSet() { + return Collections.unmodifiableSortedSet(importNameSet); + } + + /** + * パッケージ名を取得する。 + * + * @return パッケージ名 + */ + public String getPackageName() { + return packageName; + } + + /** + * クラスの単純名を取得する。 + * + * @return クラスの単純名 + */ + public String getShortClassName() { + return shortClassName; + } + + /** + * staticインポート名のソートされたセットを取得する。 + * + * @return staticインポート名のソートされたセット + */ + public SortedSet<String> getStaticImportNameSet() { + return Collections.unmodifiableSortedSet(staticImportNameSet); + } + + /** + * パッケージ名を設定する。 + * + * @param packageName パッケージ名 + */ + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + /** + * クラスの単純名を設定する。 + * + * @param shortClassName クラスの単純名 + */ + public void setShortClassName(String shortClassName) { + this.shortClassName = shortClassName; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/ClassModel.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/CompositeUniqueConstraintModel.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/CompositeUniqueConstraintModel.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/CompositeUniqueConstraintModel.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,52 +1,52 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * 複合一意制約モデル。 - * - * @author j5ik2o - */ -public class CompositeUniqueConstraintModel { - - /** カラム名のリスト */ - protected List<String> columnNameList = new ArrayList<String>(); - - - /** - * カラム名を追加する。 - * - * @param columnName カラム名 - */ - public void addColumnName(String columnName) { - columnNameList.add(columnName); - } - - /** - * カラム名のリストを取得する。 - * - * @return カラム名のリスト - */ - public List<String> getColumnNameList() { - return Collections.unmodifiableList(columnNameList); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * 複合一意制約モデル。 + * + * @author j5ik2o + */ +public class CompositeUniqueConstraintModel { + + /** カラム名のリスト */ + protected List<String> columnNameList = new ArrayList<String>(); + + + /** + * カラム名を追加する。 + * + * @param columnName カラム名 + */ + public void addColumnName(String columnName) { + columnNameList.add(columnName); + } + + /** + * カラム名のリストを取得する。 + * + * @return カラム名のリスト + */ + public List<String> getColumnNameList() { + return Collections.unmodifiableList(columnNameList); + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/CompositeUniqueConstraintModel.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/CompositeUniqueConstraintModelFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/CompositeUniqueConstraintModelFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/CompositeUniqueConstraintModelFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,36 +1,36 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model; - -import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDesc; - -/** - * {@link CompositeUniqueConstraintModel}のファクトリインターフェイス。 - * - * @author j5ik2o - */ -public interface CompositeUniqueConstraintModelFactory { - - /** - * 複合一意制約モデルを取得する。 - * - * @param compositeUniqueConstraintDesc 複合一意制約記述 - * @return 複合一意制約モデル - */ - CompositeUniqueConstraintModel getUniqueConstraintModel(CompositeUniqueConstraintDesc compositeUniqueConstraintDesc); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model; + +import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDesc; + +/** + * {@link CompositeUniqueConstraintModel}のファクトリインターフェイス。 + * + * @author j5ik2o + */ +public interface CompositeUniqueConstraintModelFactory { + + /** + * 複合一意制約モデルを取得する。 + * + * @param compositeUniqueConstraintDesc 複合一意制約記述 + * @return 複合一意制約モデル + */ + CompositeUniqueConstraintModel getUniqueConstraintModel(CompositeUniqueConstraintDesc compositeUniqueConstraintDesc); +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/CompositeUniqueConstraintModelFactory.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/EntityModel.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/EntityModel.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/EntityModel.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,264 +1,264 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model; - -import java.util.Collections; -import java.util.List; - -import org.jiemamy.utils.CollectionsUtil; - -/** - * エンティティクラスのモデルです。 - * - * @author j5ik2o - */ -public class EntityModel extends ClassModel { - - /** カタログ名 */ - protected String catalogName; - - /** スキーマ名 */ - protected String schemaName; - - /** テーブル名 */ - protected String tableName; - - /** スーパークラスの単純名 */ - protected String shortSuperclassName; - - /** 複合識別子を持つ場合{@code true} */ - protected boolean compositeId; - - /** エンティティクラスでアクセサを使用する場合 {@code true} */ - protected boolean useAccessor; - - /** コメントを使用する場合 {@code true} */ - protected boolean useComment; - - /** コメント */ - protected String comment; - - /** 属性モデルのリスト */ - protected List<AttributeModel> attributeModelList = CollectionsUtil.newArrayList(); - - /** 関連モデルのリスト */ - protected List<AssociationModel> associationModelList = CollectionsUtil.newArrayList(); - - /** 複合一意制約モデルのリスト */ - protected List<CompositeUniqueConstraintModel> compositeUniqueConstraintModelList = CollectionsUtil.newArrayList(); - - - /** - * 関連モデルを追加する。 - * - * @param associationModel 関連モデル - */ - public void addAssociationModel(AssociationModel associationModel) { - associationModelList.add(associationModel); - } - - /** - * 属性モデルを追加する。 - * - * @param attributeModel 属性モデル - */ - public void addAttributeModel(AttributeModel attributeModel) { - attributeModelList.add(attributeModel); - } - - /** - * 複合一意制約モデルを追加する。 - * - * @param compositeUniqueConstraintModel 複合一意制約モデル - */ - public void addCompositeUniqueConstraintModel(CompositeUniqueConstraintModel compositeUniqueConstraintModel) { - compositeUniqueConstraintModelList.add(compositeUniqueConstraintModel); - } - - /** - * 関連モデルのリストを取得する。 - * - * @return 関連モデルのリスト - */ - public List<AssociationModel> getAssociationModelList() { - return Collections.unmodifiableList(associationModelList); - } - - /** - * 属性モデルを取得する。 - * - * @return 属性モデル - */ - public List<AttributeModel> getAttributeModelList() { - return Collections.unmodifiableList(attributeModelList); - } - - /** - * カタログ名を取得する。 - * - * @return カタログ名 - */ - public String getCatalogName() { - return catalogName; - } - - /** - * コメントを取得する。 - * - * @return コメント - */ - public String getComment() { - return comment; - } - - /** - * 複合一意制約モデルのリストを取得する。 - * - * @return 複合一意制約モデルのリスト - */ - public List<CompositeUniqueConstraintModel> getCompositeUniqueConstraintModelList() { - return Collections.unmodifiableList(compositeUniqueConstraintModelList); - } - - /** - * スキーマ名を取得する。 - * - * @return スキーマ名 - */ - public String getSchemaName() { - return schemaName; - } - - /** - * スーパークラスの単純名を取得する。 - * - * @return スーパークラスの単純名 - */ - public String getShortSuperclassName() { - return shortSuperclassName; - } - - /** - * テーブル名を取得する。 - * - * @return テーブル名 - */ - public String getTableName() { - return tableName; - } - - /** - * 複合識別子を持つ場合{@code true}を取得する。 - * - * @return 複合識別子を持つ場合{@code true} - */ - public boolean hasCompositeId() { - return compositeId; - } - - /** - * エンティティクラスでアクセサを使用する場合 {@code true}を取得する。 - * - * @return エンティティクラスでアクセサを使用する場合 {@code true} - */ - public boolean isUseAccessor() { - return useAccessor; - } - - /** - * コメントを使用する場合 {@code true}を取得する。 - * - * @return コメントを使用する場合 {@code true} - */ - public boolean isUseComment() { - return useComment; - } - - /** - * カタログ名を設定する。 - * - * @param catalogName カタログ名 - */ - public void setCatalogName(String catalogName) { - this.catalogName = catalogName; - } - - /** - * コメントを設定する。 - * - * @param comment コメント - */ - public void setComment(String comment) { - this.comment = comment; - } - - /** - * 複合識別子を持つ場合{@code true}を設定する。 - * - * @param compositeId 複合識別子を持つ場合{@code true} - */ - public void setCompositeId(boolean compositeId) { - this.compositeId = compositeId; - } - - /** - * スキーマ名を設定する。 - * - * @param schemaName スキーマ名 - */ - public void setSchemaName(String schemaName) { - this.schemaName = schemaName; - } - - /** - * スーパークラスの単純名を設定する。 - * - * @param shortSuperclassName スーパークラスの単純名 - */ - public void setShortSuperclassName(String shortSuperclassName) { - this.shortSuperclassName = shortSuperclassName; - } - - /** - * テーブル名を設定する。 - * - * @param tableName テーブル名 - */ - public void setTableName(String tableName) { - this.tableName = tableName; - } - - /** - * エンティティクラスでアクセサを使用する場合 {@code true}を設定する。 - * - * @param useAccessor エンティティクラスでアクセサを使用する場合 {@code true} - */ - public void setUseAccessor(boolean useAccessor) { - this.useAccessor = useAccessor; - } - - /** - * コメントを使用する場合 {@code true}を設定する。 - * - * @param useComment コメントを使用する場合 {@code true} - */ - public void setUseComment(boolean useComment) { - this.useComment = useComment; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model; + +import java.util.Collections; +import java.util.List; + +import org.jiemamy.utils.CollectionsUtil; + +/** + * エンティティクラスのモデルです。 + * + * @author j5ik2o + */ +public class EntityModel extends ClassModel { + + /** カタログ名 */ + protected String catalogName; + + /** スキーマ名 */ + protected String schemaName; + + /** テーブル名 */ + protected String tableName; + + /** スーパークラスの単純名 */ + protected String shortSuperclassName; + + /** 複合識別子を持つ場合{@code true} */ + protected boolean compositeId; + + /** エンティティクラスでアクセサを使用する場合 {@code true} */ + protected boolean useAccessor; + + /** コメントを使用する場合 {@code true} */ + protected boolean useComment; + + /** コメント */ + protected String comment; + + /** 属性モデルのリスト */ + protected List<AttributeModel> attributeModelList = CollectionsUtil.newArrayList(); + + /** 関連モデルのリスト */ + protected List<AssociationModel> associationModelList = CollectionsUtil.newArrayList(); + + /** 複合一意制約モデルのリスト */ + protected List<CompositeUniqueConstraintModel> compositeUniqueConstraintModelList = CollectionsUtil.newArrayList(); + + + /** + * 関連モデルを追加する。 + * + * @param associationModel 関連モデル + */ + public void addAssociationModel(AssociationModel associationModel) { + associationModelList.add(associationModel); + } + + /** + * 属性モデルを追加する。 + * + * @param attributeModel 属性モデル + */ + public void addAttributeModel(AttributeModel attributeModel) { + attributeModelList.add(attributeModel); + } + + /** + * 複合一意制約モデルを追加する。 + * + * @param compositeUniqueConstraintModel 複合一意制約モデル + */ + public void addCompositeUniqueConstraintModel(CompositeUniqueConstraintModel compositeUniqueConstraintModel) { + compositeUniqueConstraintModelList.add(compositeUniqueConstraintModel); + } + + /** + * 関連モデルのリストを取得する。 + * + * @return 関連モデルのリスト + */ + public List<AssociationModel> getAssociationModelList() { + return Collections.unmodifiableList(associationModelList); + } + + /** + * 属性モデルを取得する。 + * + * @return 属性モデル + */ + public List<AttributeModel> getAttributeModelList() { + return Collections.unmodifiableList(attributeModelList); + } + + /** + * カタログ名を取得する。 + * + * @return カタログ名 + */ + public String getCatalogName() { + return catalogName; + } + + /** + * コメントを取得する。 + * + * @return コメント + */ + public String getComment() { + return comment; + } + + /** + * 複合一意制約モデルのリストを取得する。 + * + * @return 複合一意制約モデルのリスト + */ + public List<CompositeUniqueConstraintModel> getCompositeUniqueConstraintModelList() { + return Collections.unmodifiableList(compositeUniqueConstraintModelList); + } + + /** + * スキーマ名を取得する。 + * + * @return スキーマ名 + */ + public String getSchemaName() { + return schemaName; + } + + /** + * スーパークラスの単純名を取得する。 + * + * @return スーパークラスの単純名 + */ + public String getShortSuperclassName() { + return shortSuperclassName; + } + + /** + * テーブル名を取得する。 + * + * @return テーブル名 + */ + public String getTableName() { + return tableName; + } + + /** + * 複合識別子を持つ場合{@code true}を取得する。 + * + * @return 複合識別子を持つ場合{@code true} + */ + public boolean hasCompositeId() { + return compositeId; + } + + /** + * エンティティクラスでアクセサを使用する場合 {@code true}を取得する。 + * + * @return エンティティクラスでアクセサを使用する場合 {@code true} + */ + public boolean isUseAccessor() { + return useAccessor; + } + + /** + * コメントを使用する場合 {@code true}を取得する。 + * + * @return コメントを使用する場合 {@code true} + */ + public boolean isUseComment() { + return useComment; + } + + /** + * カタログ名を設定する。 + * + * @param catalogName カタログ名 + */ + public void setCatalogName(String catalogName) { + this.catalogName = catalogName; + } + + /** + * コメントを設定する。 + * + * @param comment コメント + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** + * 複合識別子を持つ場合{@code true}を設定する。 + * + * @param compositeId 複合識別子を持つ場合{@code true} + */ + public void setCompositeId(boolean compositeId) { + this.compositeId = compositeId; + } + + /** + * スキーマ名を設定する。 + * + * @param schemaName スキーマ名 + */ + public void setSchemaName(String schemaName) { + this.schemaName = schemaName; + } + + /** + * スーパークラスの単純名を設定する。 + * + * @param shortSuperclassName スーパークラスの単純名 + */ + public void setShortSuperclassName(String shortSuperclassName) { + this.shortSuperclassName = shortSuperclassName; + } + + /** + * テーブル名を設定する。 + * + * @param tableName テーブル名 + */ + public void setTableName(String tableName) { + this.tableName = tableName; + } + + /** + * エンティティクラスでアクセサを使用する場合 {@code true}を設定する。 + * + * @param useAccessor エンティティクラスでアクセサを使用する場合 {@code true} + */ + public void setUseAccessor(boolean useAccessor) { + this.useAccessor = useAccessor; + } + + /** + * コメントを使用する場合 {@code true}を設定する。 + * + * @param useComment コメントを使用する場合 {@code true} + */ + public void setUseComment(boolean useComment) { + this.useComment = useComment; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/EntityModel.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/EntityModelFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/EntityModelFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/EntityModelFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,36 +1,36 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model; - -import org.jiemamy.entity.io.gen.desc.EntityDesc; - -/** - * {@link EntityModel エンティティクラスのモデル}のファクトリインターフェイス。 - * - * @author j5ik2o - */ -public interface EntityModelFactory { - - /** - * エンティティクラスのモデルを取得する。 - * - * @param entityDesc エンティティ記述 - * @return エンティティクラスのモデル - */ - EntityModel getEntityModel(EntityDesc entityDesc); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model; + +import org.jiemamy.entity.io.gen.desc.EntityDesc; + +/** + * {@link EntityModel エンティティクラスのモデル}のファクトリインターフェイス。 + * + * @author j5ik2o + */ +public interface EntityModelFactory { + + /** + * エンティティクラスのモデルを取得する。 + * + * @param entityDesc エンティティ記述 + * @return エンティティクラスのモデル + */ + EntityModel getEntityModel(EntityDesc entityDesc); +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/EntityModelFactory.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/GeneratedModel.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/GeneratedModel.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/GeneratedModel.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,53 +1,53 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * 生成されるモデル。 - * - * @author j5ik2o - */ -public abstract class GeneratedModel { - - /** 生成情報のリスト */ - protected List<String> generatedInfoList = new ArrayList<String>(); - - - /** - * 生成情報を追加する。 - * - * @param generatedInfo 生成情報 - */ - public void addGeneratedInfo(String generatedInfo) { - generatedInfoList.add(generatedInfo); - } - - /** - * 生成情報のリストを取得する。 - * - * @return 生成情報のリスト - */ - public List<String> getGeneratedInfoList() { - return Collections.unmodifiableList(generatedInfoList); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * 生成されるモデル。 + * + * @author j5ik2o + */ +public abstract class GeneratedModel { + + /** 生成情報のリスト */ + protected List<String> generatedInfoList = new ArrayList<String>(); + + + /** + * 生成情報を追加する。 + * + * @param generatedInfo 生成情報 + */ + public void addGeneratedInfo(String generatedInfo) { + generatedInfoList.add(generatedInfo); + } + + /** + * 生成情報のリストを取得する。 + * + * @return 生成情報のリスト + */ + public List<String> getGeneratedInfoList() { + return Collections.unmodifiableList(generatedInfoList); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/GeneratedModel.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/JoinColumnModel.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/JoinColumnModel.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/JoinColumnModel.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,70 +1,70 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model; - -/** - * 結合カラムモデル。 - * - * @author j5ik2o - */ -public class JoinColumnModel { - - /** 参照する側のカラム名 */ - protected String name; - - /** 参照される側のカラム名 */ - protected String referencedColumnName; - - - /** - * 参照する側のカラム名を取得する。 - * - * @return 参照する側のカラム名 - */ - public String getName() { - return name; - } - - /** - * 参照される側のカラム名を取得する。 - * - * @return 参照される側のカラム名 - */ - public String getReferencedColumnName() { - return referencedColumnName; - } - - /** - * 参照する側のカラム名を取得する。 - * - * @param name 参照する側のカラム名 - */ - public void setName(String name) { - this.name = name; - } - - /** - * 参照される側のカラム名を設定する。 - * - * @param referencedColumnName 参照される側のカラム名 - */ - public void setReferencedColumnName(String referencedColumnName) { - this.referencedColumnName = referencedColumnName; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model; + +/** + * 結合カラムモデル。 + * + * @author j5ik2o + */ +public class JoinColumnModel { + + /** 参照する側のカラム名 */ + protected String name; + + /** 参照される側のカラム名 */ + protected String referencedColumnName; + + + /** + * 参照する側のカラム名を取得する。 + * + * @return 参照する側のカラム名 + */ + public String getName() { + return name; + } + + /** + * 参照される側のカラム名を取得する。 + * + * @return 参照される側のカラム名 + */ + public String getReferencedColumnName() { + return referencedColumnName; + } + + /** + * 参照する側のカラム名を取得する。 + * + * @param name 参照する側のカラム名 + */ + public void setName(String name) { + this.name = name; + } + + /** + * 参照される側のカラム名を設定する。 + * + * @param referencedColumnName 参照される側のカラム名 + */ + public void setReferencedColumnName(String referencedColumnName) { + this.referencedColumnName = referencedColumnName; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/JoinColumnModel.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/JoinColumnsModel.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/JoinColumnsModel.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/JoinColumnsModel.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,53 +1,53 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * 複合結合カラムモデル。 - * - * @author j5ik2o - */ -public class JoinColumnsModel { - - /** 結合カラムモデルのリスト */ - protected List<JoinColumnModel> joinColumnModelList = new ArrayList<JoinColumnModel>(); - - - /** - * 結合カラムモデルを追加する。 - * - * @param joinColumnModel 結合カラムモデル - */ - public void addJoinColumnModel(JoinColumnModel joinColumnModel) { - joinColumnModelList.add(joinColumnModel); - } - - /** - * 結合カラムモデルのリストを取得する。 - * - * @return 結合カラムモデルのリストを設定する。 - */ - public List<JoinColumnModel> getJoinColumnModelList() { - return Collections.unmodifiableList(joinColumnModelList); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * 複合結合カラムモデル。 + * + * @author j5ik2o + */ +public class JoinColumnsModel { + + /** 結合カラムモデルのリスト */ + protected List<JoinColumnModel> joinColumnModelList = new ArrayList<JoinColumnModel>(); + + + /** + * 結合カラムモデルを追加する。 + * + * @param joinColumnModel 結合カラムモデル + */ + public void addJoinColumnModel(JoinColumnModel joinColumnModel) { + joinColumnModelList.add(joinColumnModel); + } + + /** + * 結合カラムモデルのリストを取得する。 + * + * @return 結合カラムモデルのリストを設定する。 + */ + public List<JoinColumnModel> getJoinColumnModelList() { + return Collections.unmodifiableList(joinColumnModelList); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/JoinColumnsModel.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/UniqueKeyModel.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/UniqueKeyModel.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/UniqueKeyModel.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,95 +1,95 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * 一意キーのモデル。 - * - * @author j5ik2o - */ -public class UniqueKeyModel { - - /** 名前 */ - protected String name; - - /** カラム名のリスト */ - protected List<String> columnNameList = new ArrayList<String>(); - - /** 一意キーを削除する構文 */ - protected String dropUniqueKeySyntax; - - - /** - * カラム名を追加する。 - * - * @param columnName カラム名 - */ - public void addColumnName(String columnName) { - columnNameList.add(columnName); - } - - /** - * カラム名のリストを取得する。 - * - * @return カラム名のリスト - */ - public List<String> getColumnNameList() { - return Collections.unmodifiableList(columnNameList); - } - - /** - * 一意キーを削除する構文を取得する。 - * - * @return 一意キーを削除する構文 - */ - public String getDropUniqueKeySyntax() { - return dropUniqueKeySyntax; - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return name; - } - - /** - * 一意キーを削除する構文を設定する。 - * - * @param dropUniqueKeySyntax 一意キーを削除する構文 - */ - public void setDropUniqueKeySyntax(String dropUniqueKeySyntax) { - this.dropUniqueKeySyntax = dropUniqueKeySyntax; - } - - /** - * 名前を設定する。 - * - * @param name 名前 - */ - public void setName(String name) { - this.name = name; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * 一意キーのモデル。 + * + * @author j5ik2o + */ +public class UniqueKeyModel { + + /** 名前 */ + protected String name; + + /** カラム名のリスト */ + protected List<String> columnNameList = new ArrayList<String>(); + + /** 一意キーを削除する構文 */ + protected String dropUniqueKeySyntax; + + + /** + * カラム名を追加する。 + * + * @param columnName カラム名 + */ + public void addColumnName(String columnName) { + columnNameList.add(columnName); + } + + /** + * カラム名のリストを取得する。 + * + * @return カラム名のリスト + */ + public List<String> getColumnNameList() { + return Collections.unmodifiableList(columnNameList); + } + + /** + * 一意キーを削除する構文を取得する。 + * + * @return 一意キーを削除する構文 + */ + public String getDropUniqueKeySyntax() { + return dropUniqueKeySyntax; + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return name; + } + + /** + * 一意キーを削除する構文を設定する。 + * + * @param dropUniqueKeySyntax 一意キーを削除する構文 + */ + public void setDropUniqueKeySyntax(String dropUniqueKeySyntax) { + this.dropUniqueKeySyntax = dropUniqueKeySyntax; + } + + /** + * 名前を設定する。 + * + * @param name 名前 + */ + public void setName(String name) { + this.name = name; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/UniqueKeyModel.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/AssociationModelFactoryImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/AssociationModelFactoryImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/AssociationModelFactoryImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,118 +1,118 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model.impl; - -import javax.persistence.JoinColumn; - -import org.jiemamy.entity.io.gen.desc.AssociationDesc; -import org.jiemamy.entity.io.gen.desc.AssociationType; -import org.jiemamy.entity.io.gen.model.AssociationModel; -import org.jiemamy.entity.io.gen.model.AssociationModelFactory; -import org.jiemamy.entity.io.gen.model.JoinColumnModel; -import org.jiemamy.entity.io.gen.model.JoinColumnsModel; - -/** - * {@link AssociationModelFactory}の実装クラス。 - * - * @author j5ik2o - */ -public class AssociationModelFactoryImpl implements AssociationModelFactory { - - /** {@link JoinColumn}を表示する場合{@code true} */ - protected boolean showJoinColumn; - - - /** - * インスタンスを構築する。 - * - * @param showJoinColumn {@link JoinColumn}を表示する場合{@code true} - */ - public AssociationModelFactoryImpl(boolean showJoinColumn) { - this.showJoinColumn = showJoinColumn; - } - - /** - * 結合カラムモデルを処理する。 - * - * @param associationModel 関連モデル - * @param associationDesc 関連記述 - */ - protected void doJoinColumnModel(AssociationModel associationModel, AssociationDesc associationDesc) { - String propertyName = associationDesc.getName(); - String columnName = associationDesc.getColumnNameList().get(0); - String referencedColumnName = associationDesc.getReferencedColumnNameList().get(0); - if (showJoinColumn || !matchesDefaultMappingRule(propertyName, columnName, referencedColumnName)) { - JoinColumnModel joinColumnModel = new JoinColumnModel(); - joinColumnModel.setName(columnName); - joinColumnModel.setReferencedColumnName(referencedColumnName); - associationModel.setJoinColumnModel(joinColumnModel); - } - } - - /** - * 複合結合カラムモデルを処理する。 - * - * @param associationModel 関連モデル - * @param associationDesc 関連記述 - */ - protected void doJoinColumnsModel(AssociationModel associationModel, AssociationDesc associationDesc) { - JoinColumnsModel joinColumnsModel = new JoinColumnsModel(); - int i = 0; - for (String name : associationDesc.getColumnNameList()) { - String referencedColumnName = associationDesc.getReferencedColumnNameList().get(i); - JoinColumnModel joinColumnModel = new JoinColumnModel(); - joinColumnModel.setName(name); - joinColumnModel.setReferencedColumnName(referencedColumnName); - joinColumnsModel.addJoinColumnModel(joinColumnModel); - i++; - } - associationModel.setJoinColumnsModel(joinColumnsModel); - } - - public AssociationModel getAssociationModel(AssociationDesc associationDesc) { - AssociationModel model = new AssociationModel(); - model.setName(associationDesc.getName()); - if (associationDesc.getAssociationType() == AssociationType.ONE_TO_MANY) { - String entityName = associationDesc.getReferencedEntityDesc().getName(); - model.setShortClassName("List<" + entityName + ">"); - } else { - model.setShortClassName(associationDesc.getReferencedEntityDesc().getName()); - } - model.setAssociationType(associationDesc.getAssociationType()); - model.setMappedBy(associationDesc.getMappedBy()); - if (associationDesc.getColumnNameList().size() == 1) { - doJoinColumnModel(model, associationDesc); - } else if (associationDesc.getColumnNameList().size() > 1) { - doJoinColumnsModel(model, associationDesc); - } - return model; - } - - /** - * 結合カラムのデフォルトのマッピングルールに合致する場合{@code true}を取得する。 - * - * @param propertyName プロパティ名 - * @param columnName 参照する側のカラム名 - * @param referencedColumnName 参照される側のカラム名 - * @return 結合カラムの命名規約に合致する場合{@code true} - */ - protected boolean matchesDefaultMappingRule(String propertyName, String columnName, String referencedColumnName) { - return columnName.equalsIgnoreCase(propertyName + "_" + referencedColumnName); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model.impl; + +import javax.persistence.JoinColumn; + +import org.jiemamy.entity.io.gen.desc.AssociationDesc; +import org.jiemamy.entity.io.gen.desc.AssociationType; +import org.jiemamy.entity.io.gen.model.AssociationModel; +import org.jiemamy.entity.io.gen.model.AssociationModelFactory; +import org.jiemamy.entity.io.gen.model.JoinColumnModel; +import org.jiemamy.entity.io.gen.model.JoinColumnsModel; + +/** + * {@link AssociationModelFactory}の実装クラス。 + * + * @author j5ik2o + */ +public class AssociationModelFactoryImpl implements AssociationModelFactory { + + /** {@link JoinColumn}を表示する場合{@code true} */ + protected boolean showJoinColumn; + + + /** + * インスタンスを構築する。 + * + * @param showJoinColumn {@link JoinColumn}を表示する場合{@code true} + */ + public AssociationModelFactoryImpl(boolean showJoinColumn) { + this.showJoinColumn = showJoinColumn; + } + + /** + * 結合カラムモデルを処理する。 + * + * @param associationModel 関連モデル + * @param associationDesc 関連記述 + */ + protected void doJoinColumnModel(AssociationModel associationModel, AssociationDesc associationDesc) { + String propertyName = associationDesc.getName(); + String columnName = associationDesc.getColumnNameList().get(0); + String referencedColumnName = associationDesc.getReferencedColumnNameList().get(0); + if (showJoinColumn || !matchesDefaultMappingRule(propertyName, columnName, referencedColumnName)) { + JoinColumnModel joinColumnModel = new JoinColumnModel(); + joinColumnModel.setName(columnName); + joinColumnModel.setReferencedColumnName(referencedColumnName); + associationModel.setJoinColumnModel(joinColumnModel); + } + } + + /** + * 複合結合カラムモデルを処理する。 + * + * @param associationModel 関連モデル + * @param associationDesc 関連記述 + */ + protected void doJoinColumnsModel(AssociationModel associationModel, AssociationDesc associationDesc) { + JoinColumnsModel joinColumnsModel = new JoinColumnsModel(); + int i = 0; + for (String name : associationDesc.getColumnNameList()) { + String referencedColumnName = associationDesc.getReferencedColumnNameList().get(i); + JoinColumnModel joinColumnModel = new JoinColumnModel(); + joinColumnModel.setName(name); + joinColumnModel.setReferencedColumnName(referencedColumnName); + joinColumnsModel.addJoinColumnModel(joinColumnModel); + i++; + } + associationModel.setJoinColumnsModel(joinColumnsModel); + } + + public AssociationModel getAssociationModel(AssociationDesc associationDesc) { + AssociationModel model = new AssociationModel(); + model.setName(associationDesc.getName()); + if (associationDesc.getAssociationType() == AssociationType.ONE_TO_MANY) { + String entityName = associationDesc.getReferencedEntityDesc().getName(); + model.setShortClassName("List<" + entityName + ">"); + } else { + model.setShortClassName(associationDesc.getReferencedEntityDesc().getName()); + } + model.setAssociationType(associationDesc.getAssociationType()); + model.setMappedBy(associationDesc.getMappedBy()); + if (associationDesc.getColumnNameList().size() == 1) { + doJoinColumnModel(model, associationDesc); + } else if (associationDesc.getColumnNameList().size() > 1) { + doJoinColumnsModel(model, associationDesc); + } + return model; + } + + /** + * 結合カラムのデフォルトのマッピングルールに合致する場合{@code true}を取得する。 + * + * @param propertyName プロパティ名 + * @param columnName 参照する側のカラム名 + * @param referencedColumnName 参照される側のカラム名 + * @return 結合カラムの命名規約に合致する場合{@code true} + */ + protected boolean matchesDefaultMappingRule(String propertyName, String columnName, String referencedColumnName) { + return columnName.equalsIgnoreCase(propertyName + "_" + referencedColumnName); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/AssociationModelFactoryImpl.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/AttributeModelFactoryImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/AttributeModelFactoryImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/AttributeModelFactoryImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,182 +1,182 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model.impl; - -import java.math.BigDecimal; -import java.util.Calendar; -import java.util.Date; - -import javax.persistence.TemporalType; - -import org.jiemamy.entity.io.convensition.PersistenceConvention; -import org.jiemamy.entity.io.gen.desc.AttributeDesc; -import org.jiemamy.entity.io.gen.model.AttributeModel; -import org.jiemamy.entity.io.gen.model.AttributeModelFactory; -import org.jiemamy.utils.ClassUtil; - -/** - * {@link AttributeModelFactory}の実装クラス。 - * - * @author j5ik2o - */ -public class AttributeModelFactoryImpl implements AttributeModelFactory { - - /** カラム名を表示する場合{@code true} */ - protected boolean showColumnName; - - /** カラム定義を表示する場合{@code true} */ - protected boolean showColumnDefinition; - - /** {@link TemporalType}を使用する場合{@code true} */ - protected boolean useTemporalType; - - /** 永続化層の命名規約 */ - protected PersistenceConvention persistenceConvention; - - - /** - * インスタンスを生成する。 - * - * @param persistenceConvention 永続化層の命名規約 - * @param showColumnName カラム名を表示する場合{@code true} - * @param showColumnDefinition カラム定義を表示する場合{@code true} - * @param useTemporalType {@link TemporalType}を使用する場合{@code true} - */ - public AttributeModelFactoryImpl(PersistenceConvention persistenceConvention, boolean showColumnName, - boolean showColumnDefinition, boolean useTemporalType) { - this.persistenceConvention = persistenceConvention; - this.showColumnName = showColumnName; - this.showColumnDefinition = showColumnDefinition; - this.useTemporalType = useTemporalType; - } - - /** - * 属性のクラスを処理する。 - * - * @param attributeModel 属性モデル - * @param attributeDesc 属性記述 - */ - protected void doAttributeClass(AttributeModel attributeModel, AttributeDesc attributeDesc) { - if (useTemporalType && attributeDesc.isTemporal()) { - attributeModel.setTemporalType(attributeDesc.getTemporalType()); - attributeModel.setAttributeClass(Date.class); - } else { - attributeModel.setAttributeClass(attributeDesc.getAttributeClass()); - } - } - - /** - * カラム定義を処理する。 - * - * @param attributeModel 属性モデル - * @param attributeDesc 属性記述 - */ - protected void doColumnDefinition(AttributeModel attributeModel, AttributeDesc attributeDesc) { - attributeModel.setColumnDefinition(attributeDesc.getColumnDefinition()); - attributeModel.setUnsupportedColumnType(attributeDesc.isUnsupportedColumnType()); - } - - /** - * カラム名を処理する。 - * - * @param attributeModel 属性モデル - * @param attributeDesc 属性記述 - */ - protected void doColumnName(AttributeModel attributeModel, AttributeDesc attributeDesc) { - String realColumnName = attributeDesc.getColumnName(); - String convertedColumnName = persistenceConvention.fromPropertyNameToColumnName(attributeModel.getName()); - if (showColumnName || !realColumnName.equalsIgnoreCase(convertedColumnName)) { - attributeModel.setColumnName(realColumnName); - } - } - - /** - * 長さを処理する。 - * - * @param attributeModel 属性モデル - * @param attributeDesc 属性記述 - */ - protected void doLength(AttributeModel attributeModel, AttributeDesc attributeDesc) { - if (attributeDesc.getLength() < 1) { - return; - } - Class<?> clazz = ClassUtil.getWrapperClassIfPrimitive(attributeDesc.getAttributeClass()); - if (!Number.class.isAssignableFrom(clazz) && !Date.class.isAssignableFrom(clazz) - && !Calendar.class.isAssignableFrom(clazz)) { - attributeModel.setLength(attributeDesc.getLength()); - } - } - - /** - * 精度を処理する。 - * - * @param attributeModel 属性モデル - * @param attributeDesc 属性記述 - */ - protected void doPrecision(AttributeModel attributeModel, AttributeDesc attributeDesc) { - if (attributeDesc.getPrecision() < 1) { - return; - } - Class<?> clazz = ClassUtil.getWrapperClassIfPrimitive(attributeDesc.getAttributeClass()); - if (Number.class.isAssignableFrom(clazz)) { - attributeModel.setPrecision(attributeDesc.getPrecision()); - } - } - - /** - * スケールを処理する。 - * - * @param attributeModel 属性モデル - * @param attributeDesc 属性記述 - */ - protected void doScale(AttributeModel attributeModel, AttributeDesc attributeDesc) { - if (attributeDesc.getScale() < 1) { - return; - } - Class<?> clazz = ClassUtil.getWrapperClassIfPrimitive(attributeDesc.getAttributeClass()); - if (clazz == BigDecimal.class || clazz == Float.class || clazz == Double.class) { - attributeModel.setScale(attributeDesc.getScale()); - } - } - - public AttributeModel getAttributeModel(AttributeDesc attributeDesc) { - AttributeModel attributeModel = new AttributeModel(); - attributeModel.setName(attributeDesc.getName()); - attributeModel.setId(attributeDesc.isId()); - attributeModel.setGenerationType(attributeDesc.getGenerationType()); - attributeModel.setInitialValue(attributeDesc.getInitialValue()); - attributeModel.setAllocationSize(attributeDesc.getAllocationSize()); - attributeModel.setLob(attributeDesc.isLob()); - attributeModel.setTransient(attributeDesc.isTransient()); - attributeModel.setVersion(attributeDesc.isVersion()); - attributeModel.setNullable(attributeDesc.isNullable()); - attributeModel.setUnique(attributeDesc.isUnique()); - attributeModel.setColumnTypeName(attributeDesc.getColumnTypeName()); - attributeModel.setComment(attributeDesc.getComment()); - doAttributeClass(attributeModel, attributeDesc); - doColumnName(attributeModel, attributeDesc); - if (showColumnDefinition) { - doColumnDefinition(attributeModel, attributeDesc); - } else { - doLength(attributeModel, attributeDesc); - doPrecision(attributeModel, attributeDesc); - doScale(attributeModel, attributeDesc); - } - return attributeModel; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model.impl; + +import java.math.BigDecimal; +import java.util.Calendar; +import java.util.Date; + +import javax.persistence.TemporalType; + +import org.jiemamy.entity.io.convensition.PersistenceConvention; +import org.jiemamy.entity.io.gen.desc.AttributeDesc; +import org.jiemamy.entity.io.gen.model.AttributeModel; +import org.jiemamy.entity.io.gen.model.AttributeModelFactory; +import org.jiemamy.utils.ClassUtil; + +/** + * {@link AttributeModelFactory}の実装クラス。 + * + * @author j5ik2o + */ +public class AttributeModelFactoryImpl implements AttributeModelFactory { + + /** カラム名を表示する場合{@code true} */ + protected boolean showColumnName; + + /** カラム定義を表示する場合{@code true} */ + protected boolean showColumnDefinition; + + /** {@link TemporalType}を使用する場合{@code true} */ + protected boolean useTemporalType; + + /** 永続化層の命名規約 */ + protected PersistenceConvention persistenceConvention; + + + /** + * インスタンスを生成する。 + * + * @param persistenceConvention 永続化層の命名規約 + * @param showColumnName カラム名を表示する場合{@code true} + * @param showColumnDefinition カラム定義を表示する場合{@code true} + * @param useTemporalType {@link TemporalType}を使用する場合{@code true} + */ + public AttributeModelFactoryImpl(PersistenceConvention persistenceConvention, boolean showColumnName, + boolean showColumnDefinition, boolean useTemporalType) { + this.persistenceConvention = persistenceConvention; + this.showColumnName = showColumnName; + this.showColumnDefinition = showColumnDefinition; + this.useTemporalType = useTemporalType; + } + + /** + * 属性のクラスを処理する。 + * + * @param attributeModel 属性モデル + * @param attributeDesc 属性記述 + */ + protected void doAttributeClass(AttributeModel attributeModel, AttributeDesc attributeDesc) { + if (useTemporalType && attributeDesc.isTemporal()) { + attributeModel.setTemporalType(attributeDesc.getTemporalType()); + attributeModel.setAttributeClass(Date.class); + } else { + attributeModel.setAttributeClass(attributeDesc.getAttributeClass()); + } + } + + /** + * カラム定義を処理する。 + * + * @param attributeModel 属性モデル + * @param attributeDesc 属性記述 + */ + protected void doColumnDefinition(AttributeModel attributeModel, AttributeDesc attributeDesc) { + attributeModel.setColumnDefinition(attributeDesc.getColumnDefinition()); + attributeModel.setUnsupportedColumnType(attributeDesc.isUnsupportedColumnType()); + } + + /** + * カラム名を処理する。 + * + * @param attributeModel 属性モデル + * @param attributeDesc 属性記述 + */ + protected void doColumnName(AttributeModel attributeModel, AttributeDesc attributeDesc) { + String realColumnName = attributeDesc.getColumnName(); + String convertedColumnName = persistenceConvention.fromPropertyNameToColumnName(attributeModel.getName()); + if (showColumnName || !realColumnName.equalsIgnoreCase(convertedColumnName)) { + attributeModel.setColumnName(realColumnName); + } + } + + /** + * 長さを処理する。 + * + * @param attributeModel 属性モデル + * @param attributeDesc 属性記述 + */ + protected void doLength(AttributeModel attributeModel, AttributeDesc attributeDesc) { + if (attributeDesc.getLength() < 1) { + return; + } + Class<?> clazz = ClassUtil.getWrapperClassIfPrimitive(attributeDesc.getAttributeClass()); + if (!Number.class.isAssignableFrom(clazz) && !Date.class.isAssignableFrom(clazz) + && !Calendar.class.isAssignableFrom(clazz)) { + attributeModel.setLength(attributeDesc.getLength()); + } + } + + /** + * 精度を処理する。 + * + * @param attributeModel 属性モデル + * @param attributeDesc 属性記述 + */ + protected void doPrecision(AttributeModel attributeModel, AttributeDesc attributeDesc) { + if (attributeDesc.getPrecision() < 1) { + return; + } + Class<?> clazz = ClassUtil.getWrapperClassIfPrimitive(attributeDesc.getAttributeClass()); + if (Number.class.isAssignableFrom(clazz)) { + attributeModel.setPrecision(attributeDesc.getPrecision()); + } + } + + /** + * スケールを処理する。 + * + * @param attributeModel 属性モデル + * @param attributeDesc 属性記述 + */ + protected void doScale(AttributeModel attributeModel, AttributeDesc attributeDesc) { + if (attributeDesc.getScale() < 1) { + return; + } + Class<?> clazz = ClassUtil.getWrapperClassIfPrimitive(attributeDesc.getAttributeClass()); + if (clazz == BigDecimal.class || clazz == Float.class || clazz == Double.class) { + attributeModel.setScale(attributeDesc.getScale()); + } + } + + public AttributeModel getAttributeModel(AttributeDesc attributeDesc) { + AttributeModel attributeModel = new AttributeModel(); + attributeModel.setName(attributeDesc.getName()); + attributeModel.setId(attributeDesc.isId()); + attributeModel.setGenerationType(attributeDesc.getGenerationType()); + attributeModel.setInitialValue(attributeDesc.getInitialValue()); + attributeModel.setAllocationSize(attributeDesc.getAllocationSize()); + attributeModel.setLob(attributeDesc.isLob()); + attributeModel.setTransient(attributeDesc.isTransient()); + attributeModel.setVersion(attributeDesc.isVersion()); + attributeModel.setNullable(attributeDesc.isNullable()); + attributeModel.setUnique(attributeDesc.isUnique()); + attributeModel.setColumnTypeName(attributeDesc.getColumnTypeName()); + attributeModel.setComment(attributeDesc.getComment()); + doAttributeClass(attributeModel, attributeDesc); + doColumnName(attributeModel, attributeDesc); + if (showColumnDefinition) { + doColumnDefinition(attributeModel, attributeDesc); + } else { + doLength(attributeModel, attributeDesc); + doPrecision(attributeModel, attributeDesc); + doScale(attributeModel, attributeDesc); + } + return attributeModel; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/AttributeModelFactoryImpl.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/ClassModelSupport.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/ClassModelSupport.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/ClassModelSupport.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,115 +1,115 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model.impl; - -import org.jiemamy.entity.io.gen.model.ClassModel; -import org.jiemamy.utils.ClassUtil; - -/** - * {@link ClassModel}のサポートクラス。 - * - * @author j5ik2o - */ -public class ClassModelSupport { - - /** - * クラスモデルにインポート名を追加する。 - * - * @param classModel クラスモデル - * @param importClass インポート対象のクラス - */ - public void addImportName(ClassModel classModel, Class<?> importClass) { - String importedPackageName = ClassUtil.getPackageName(importClass); - if (isImportTargetPackage(classModel, importedPackageName)) { - classModel.addImportName(importClass.getName()); - } - } - - /** - * クラスモデルにインポート名を追加する。 - * - * @param classModel クラスモデル - * @param importClassName インポート対象のクラス名 - */ - public void addImportName(ClassModel classModel, String importClassName) { - String importedPackageName = ClassUtil.splitPackageAndShortClassName(importClassName)[0]; - if (isImportTargetPackage(classModel, importedPackageName)) { - classModel.addImportName(importClassName); - } - } - - /** - * クラスモデルにstaticインポート名を追加する。 - * - * @param classModel クラスモデル - * @param importClass インポート対象のクラス - */ - public void addStaticImportName(ClassModel classModel, Class<?> importClass) { - String importedPackageName = ClassUtil.getPackageName(importClass); - if (isStaticImportTargetPackage(classModel, importedPackageName)) { - classModel.addStaticImportName(importClass.getName() + ".*"); - } - } - - /** - * クラスモデルにstaticインポート名を追加する。 - * - * @param classModel クラスモデル - * @param importClassName インポート対象のクラス名 - */ - public void addStaticImportName(ClassModel classModel, String importClassName) { - String importedPackageName = ClassUtil.splitPackageAndShortClassName(importClassName)[0]; - if (isStaticImportTargetPackage(classModel, importedPackageName)) { - classModel.addStaticImportName(importClassName + ".*"); - } - } - - /** - * インポートが必要なパッケージの場合{@code true}を取得する。 - * - * @param classModel クラスモデル - * @param importPackageName インポートするパッケージ名 - * @return インポートが必要なパッケージの場合{@code true} - */ - protected boolean isImportTargetPackage(ClassModel classModel, String importPackageName) { - if (importPackageName == null) { - return false; - } - if (importPackageName.equals(classModel.getPackageName())) { - return false; - } - if (importPackageName.equals("java.lang")) { - return false; - } - return true; - } - - /** - * staticインポートが必要なパッケージの場合{@code true}を取得する。 - * - * @param classModel クラスモデル - * @param importPackageName インポートするパッケージ名 - * @return インポートが必要なパッケージの場合{@code true} - */ - protected boolean isStaticImportTargetPackage(ClassModel classModel, String importPackageName) { - if (importPackageName == null) { - return false; - } - return true; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model.impl; + +import org.jiemamy.entity.io.gen.model.ClassModel; +import org.jiemamy.utils.ClassUtil; + +/** + * {@link ClassModel}のサポートクラス。 + * + * @author j5ik2o + */ +public class ClassModelSupport { + + /** + * クラスモデルにインポート名を追加する。 + * + * @param classModel クラスモデル + * @param importClass インポート対象のクラス + */ + public void addImportName(ClassModel classModel, Class<?> importClass) { + String importedPackageName = ClassUtil.getPackageName(importClass); + if (isImportTargetPackage(classModel, importedPackageName)) { + classModel.addImportName(importClass.getName()); + } + } + + /** + * クラスモデルにインポート名を追加する。 + * + * @param classModel クラスモデル + * @param importClassName インポート対象のクラス名 + */ + public void addImportName(ClassModel classModel, String importClassName) { + String importedPackageName = ClassUtil.splitPackageAndShortClassName(importClassName)[0]; + if (isImportTargetPackage(classModel, importedPackageName)) { + classModel.addImportName(importClassName); + } + } + + /** + * クラスモデルにstaticインポート名を追加する。 + * + * @param classModel クラスモデル + * @param importClass インポート対象のクラス + */ + public void addStaticImportName(ClassModel classModel, Class<?> importClass) { + String importedPackageName = ClassUtil.getPackageName(importClass); + if (isStaticImportTargetPackage(classModel, importedPackageName)) { + classModel.addStaticImportName(importClass.getName() + ".*"); + } + } + + /** + * クラスモデルにstaticインポート名を追加する。 + * + * @param classModel クラスモデル + * @param importClassName インポート対象のクラス名 + */ + public void addStaticImportName(ClassModel classModel, String importClassName) { + String importedPackageName = ClassUtil.splitPackageAndShortClassName(importClassName)[0]; + if (isStaticImportTargetPackage(classModel, importedPackageName)) { + classModel.addStaticImportName(importClassName + ".*"); + } + } + + /** + * インポートが必要なパッケージの場合{@code true}を取得する。 + * + * @param classModel クラスモデル + * @param importPackageName インポートするパッケージ名 + * @return インポートが必要なパッケージの場合{@code true} + */ + protected boolean isImportTargetPackage(ClassModel classModel, String importPackageName) { + if (importPackageName == null) { + return false; + } + if (importPackageName.equals(classModel.getPackageName())) { + return false; + } + if (importPackageName.equals("java.lang")) { + return false; + } + return true; + } + + /** + * staticインポートが必要なパッケージの場合{@code true}を取得する。 + * + * @param classModel クラスモデル + * @param importPackageName インポートするパッケージ名 + * @return インポートが必要なパッケージの場合{@code true} + */ + protected boolean isStaticImportTargetPackage(ClassModel classModel, String importPackageName) { + if (importPackageName == null) { + return false; + } + return true; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/ClassModelSupport.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/CompositeUniqueConstraintModelFactoryImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/CompositeUniqueConstraintModelFactoryImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/CompositeUniqueConstraintModelFactoryImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,39 +1,39 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model.impl; - -import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDesc; -import org.jiemamy.entity.io.gen.model.CompositeUniqueConstraintModel; -import org.jiemamy.entity.io.gen.model.CompositeUniqueConstraintModelFactory; - -/** - * {@link CompositeUniqueConstraintModelFactory}の実装クラス。 - * - * @author j5ik2o - */ -public class CompositeUniqueConstraintModelFactoryImpl implements CompositeUniqueConstraintModelFactory { - - public CompositeUniqueConstraintModel getUniqueConstraintModel( - CompositeUniqueConstraintDesc compositeUniqueConstraintDesc) { - CompositeUniqueConstraintModel compositeUniqueConstraintModel = new CompositeUniqueConstraintModel(); - for (String columnName : compositeUniqueConstraintDesc.getColumnNameList()) { - compositeUniqueConstraintModel.addColumnName(columnName); - } - return compositeUniqueConstraintModel; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model.impl; + +import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDesc; +import org.jiemamy.entity.io.gen.model.CompositeUniqueConstraintModel; +import org.jiemamy.entity.io.gen.model.CompositeUniqueConstraintModelFactory; + +/** + * {@link CompositeUniqueConstraintModelFactory}の実装クラス。 + * + * @author j5ik2o + */ +public class CompositeUniqueConstraintModelFactoryImpl implements CompositeUniqueConstraintModelFactory { + + public CompositeUniqueConstraintModel getUniqueConstraintModel( + CompositeUniqueConstraintDesc compositeUniqueConstraintDesc) { + CompositeUniqueConstraintModel compositeUniqueConstraintModel = new CompositeUniqueConstraintModel(); + for (String columnName : compositeUniqueConstraintDesc.getColumnNameList()) { + compositeUniqueConstraintModel.addColumnName(columnName); + } + return compositeUniqueConstraintModel; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/CompositeUniqueConstraintModelFactoryImpl.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/EntityModelFactoryImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/EntityModelFactoryImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/EntityModelFactoryImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,294 +1,294 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model.impl; - -import java.io.Serializable; -import java.util.List; - -import javax.annotation.Generated; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinColumns; -import javax.persistence.Lob; -import javax.persistence.SequenceGenerator; -import javax.persistence.Table; -import javax.persistence.TableGenerator; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import javax.persistence.UniqueConstraint; -import javax.persistence.Version; - -import org.jiemamy.entity.io.gen.desc.AssociationDesc; -import org.jiemamy.entity.io.gen.desc.AssociationType; -import org.jiemamy.entity.io.gen.desc.AttributeDesc; -import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDesc; -import org.jiemamy.entity.io.gen.desc.EntityDesc; -import org.jiemamy.entity.io.gen.model.AssociationModel; -import org.jiemamy.entity.io.gen.model.AssociationModelFactory; -import org.jiemamy.entity.io.gen.model.AttributeModel; -import org.jiemamy.entity.io.gen.model.AttributeModelFactory; -import org.jiemamy.entity.io.gen.model.CompositeUniqueConstraintModel; -import org.jiemamy.entity.io.gen.model.CompositeUniqueConstraintModelFactory; -import org.jiemamy.entity.io.gen.model.EntityModel; -import org.jiemamy.entity.io.gen.model.EntityModelFactory; -import org.jiemamy.utils.ClassUtil; - -/** - * {@link EntityModelFactory}の実装クラス。 - * - * @author j5ik2o - */ -public class EntityModelFactoryImpl implements EntityModelFactory { - - /** パッケージ名、デフォルトパッケージの場合は{@code null} */ - protected String packageName; - - /** 属性モデルのファクトリ */ - protected AttributeModelFactory attributeModelFactory; - - /** 関連モデルのファクトリ */ - protected AssociationModelFactory associationModelFactory; - - /** 複合一意制約モデルのファクトリ */ - protected CompositeUniqueConstraintModelFactory compositeUniqueConstraintModelFactory; - - /** エンティティクラスでアクセサを使用する場合 {@code true} */ - protected boolean useAccessor; - - /** コメントを使用する場合{@code true} */ - protected boolean useComment; - - /** カタログ名を表示する場合{@code true} */ - protected boolean showCatalogName; - - /** スキーマ名を表示する場合{@code true} */ - protected boolean showSchemaName; - - /** テーブル名を表示する場合{@code true} */ - protected boolean showTableName; - - /** エンティティのスーパークラス、スーパークラスを持たない場合は{@code null} */ - protected Class<?> superclass; - - /** クラスモデルのサポート */ - protected ClassModelSupport classModelSupport = new ClassModelSupport(); - - /** 生成モデルのサポート */ - protected GeneratedModelSupport generatedModelSupport = new GeneratedModelSupport(); - - - /** - * インスタンスを生成する。 - * - * @param packageName パッケージ名、デフォルトパッケージの場合は{@code null} - * @param superclass エンティティのスーパークラス、スーパークラスを持たない場合は{@code null} - * @param attributeModelFactory 属性モデルのファクトリ - * @param associationModelFactory 関連モデルのファクトリ - * @param compositeUniqueConstraintModelFactory 複合一意制約モデルのファクトリ - * @param useAccessor エンティティクラスでアクセサを使用する場合 {@code true} - * @param useComment コメントを使用する場合{@code true} - * @param showCatalogName カタログ名を表示する場合{@code true} - * @param showSchemaName スキーマ名を表示する場合{@code true} - * @param showTableName テーブル名を表示する場合{@code true} - */ - public EntityModelFactoryImpl(String packageName, Class<?> superclass, AttributeModelFactory attributeModelFactory, - AssociationModelFactory associationModelFactory, - CompositeUniqueConstraintModelFactory compositeUniqueConstraintModelFactory, boolean useAccessor, - boolean useComment, boolean showCatalogName, boolean showSchemaName, boolean showTableName) { - if (attributeModelFactory == null) { - throw new NullPointerException("attributeModelFactory"); - } - if (associationModelFactory == null) { - throw new NullPointerException("associationModelFactory"); - } - if (compositeUniqueConstraintModelFactory == null) { - throw new NullPointerException("compositeUniqueConstraintModelFactory"); - } - this.packageName = packageName; - this.superclass = superclass; - this.attributeModelFactory = attributeModelFactory; - this.associationModelFactory = associationModelFactory; - this.compositeUniqueConstraintModelFactory = compositeUniqueConstraintModelFactory; - this.useAccessor = useAccessor; - this.useComment = useComment; - this.showCatalogName = showCatalogName; - this.showSchemaName = showSchemaName; - this.showTableName = showTableName; -// if (superclass != null) { -// if (superclass.isAnnotationPresent(MappedSuperclass.class)) { -// mappedSuperclassBeanDesc = BeanDescFactory.getBeanDesc(superclass); -// } -// } - } - - /** - * 関連モデルを処理する。 - * - * @param entityModel エンティティモデル - * @param entityDesc エンティティ記述 - */ - protected void doAssociationModel(EntityModel entityModel, EntityDesc entityDesc) { - for (AssociationDesc associationDesc : entityDesc.getAssociationDescList()) { - if (superclass != null && ClassUtil.getFieldNoException(superclass, associationDesc.getName()) != null) { - continue; - } - AssociationModel associationModel = associationModelFactory.getAssociationModel(associationDesc); - entityModel.addAssociationModel(associationModel); - } - } - - /** - * 属性モデルを処理する。 - * - * @param entityModel エンティティモデル - * @param entityDesc エンティティ記述 - */ - protected void doAttributeModel(EntityModel entityModel, EntityDesc entityDesc) { - for (AttributeDesc attributeDesc : entityDesc.getAttributeDescList()) { - if (superclass != null && ClassUtil.getFieldNoException(superclass, attributeDesc.getName()) != null) { - continue; - } - AttributeModel attributeModel = attributeModelFactory.getAttributeModel(attributeDesc); - entityModel.addAttributeModel(attributeModel); - } - } - - /** - * 複合一意制約モデルを処理する。 - * - * @param entityModel エンティティモデル - * @param entityDesc エンティティ記述 - */ - protected void doCompositeUniqueConstraintModel(EntityModel entityModel, EntityDesc entityDesc) { - for (CompositeUniqueConstraintDesc compositeUniqueConstraintDesc : entityDesc - .getCompositeUniqueConstraintDescList()) { - CompositeUniqueConstraintModel compositeUniqueConstraintModel = - compositeUniqueConstraintModelFactory.getUniqueConstraintModel(compositeUniqueConstraintDesc); - entityModel.addCompositeUniqueConstraintModel(compositeUniqueConstraintModel); - } - } - - /** - * 生成情報を処理する。 - * - * @param entityModel エンティティモデル - * @param entityDesc エンティティ記述 - */ - protected void doGeneratedInfo(EntityModel entityModel, EntityDesc entityDesc) { - generatedModelSupport.fillGeneratedInfo(this, entityModel); - } - - /** - * インポート名を処理する。 - * - * @param model エンティティクラスのモデル - * @param entityDesc エンティティ記述 - */ - protected void doImportName(EntityModel model, EntityDesc entityDesc) { - classModelSupport.addImportName(model, Entity.class); - classModelSupport.addImportName(model, Serializable.class); - classModelSupport.addImportName(model, Generated.class); - if (model.getCatalogName() != null || model.getSchemaName() != null || model.getTableName() != null) { - classModelSupport.addImportName(model, Table.class); - } - if (superclass != null) { - classModelSupport.addImportName(model, superclass); - } - for (AttributeModel attr : model.getAttributeModelList()) { - if (attr.isId()) { - classModelSupport.addImportName(model, Id.class); - if (attr.getGenerationType() != null) { - classModelSupport.addImportName(model, GeneratedValue.class); - classModelSupport.addImportName(model, GenerationType.class); - if (attr.getGenerationType() == GenerationType.SEQUENCE) { - classModelSupport.addImportName(model, SequenceGenerator.class); - } else if (attr.getGenerationType() == GenerationType.TABLE) { - classModelSupport.addImportName(model, TableGenerator.class); - } - } - } - if (attr.isLob()) { - classModelSupport.addImportName(model, Lob.class); - } - if (attr.getTemporalType() != null) { - classModelSupport.addImportName(model, Temporal.class); - classModelSupport.addImportName(model, TemporalType.class); - } - if (attr.isTransient()) { - classModelSupport.addImportName(model, Transient.class); - } else { - classModelSupport.addImportName(model, Column.class); - } - if (attr.isVersion()) { - classModelSupport.addImportName(model, Version.class); - } - classModelSupport.addImportName(model, attr.getAttributeClass()); - } - for (AssociationModel asso : model.getAssociationModelList()) { - AssociationType associationType = asso.getAssociationType(); - if (associationType == AssociationType.ONE_TO_MANY) { - classModelSupport.addImportName(model, List.class); - } - classModelSupport.addImportName(model, associationType.getAnnotation()); - if (asso.getJoinColumnModel() != null) { - classModelSupport.addImportName(model, JoinColumn.class); - } - if (asso.getJoinColumnsModel() != null) { - classModelSupport.addImportName(model, JoinColumn.class); - classModelSupport.addImportName(model, JoinColumns.class); - } - } - if (!model.getCompositeUniqueConstraintModelList().isEmpty()) { - classModelSupport.addImportName(model, Table.class); - classModelSupport.addImportName(model, UniqueConstraint.class); - } - } - - public EntityModel getEntityModel(EntityDesc entityDesc) { - EntityModel entityModel = new EntityModel(); - if (showCatalogName) { - entityModel.setCatalogName(entityDesc.getCatalogName()); - } - if (showSchemaName) { - entityModel.setSchemaName(entityDesc.getSchemaName()); - } - if (showTableName) { - entityModel.setTableName(entityDesc.getTableName()); - } - entityModel.setPackageName(packageName); - entityModel.setShortClassName(entityDesc.getName()); - if (superclass != null) { - entityModel.setShortSuperclassName(superclass.getSimpleName()); - } - entityModel.setCompositeId(entityDesc.hasCompositeId()); - entityModel.setUseAccessor(useAccessor); - entityModel.setComment(entityDesc.getComment()); - entityModel.setUseComment(useComment); - doAttributeModel(entityModel, entityDesc); - doAssociationModel(entityModel, entityDesc); - doCompositeUniqueConstraintModel(entityModel, entityDesc); - doImportName(entityModel, entityDesc); - doGeneratedInfo(entityModel, entityDesc); - return entityModel; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model.impl; + +import java.io.Serializable; +import java.util.List; + +import javax.annotation.Generated; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.Lob; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.TableGenerator; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; +import javax.persistence.UniqueConstraint; +import javax.persistence.Version; + +import org.jiemamy.entity.io.gen.desc.AssociationDesc; +import org.jiemamy.entity.io.gen.desc.AssociationType; +import org.jiemamy.entity.io.gen.desc.AttributeDesc; +import org.jiemamy.entity.io.gen.desc.CompositeUniqueConstraintDesc; +import org.jiemamy.entity.io.gen.desc.EntityDesc; +import org.jiemamy.entity.io.gen.model.AssociationModel; +import org.jiemamy.entity.io.gen.model.AssociationModelFactory; +import org.jiemamy.entity.io.gen.model.AttributeModel; +import org.jiemamy.entity.io.gen.model.AttributeModelFactory; +import org.jiemamy.entity.io.gen.model.CompositeUniqueConstraintModel; +import org.jiemamy.entity.io.gen.model.CompositeUniqueConstraintModelFactory; +import org.jiemamy.entity.io.gen.model.EntityModel; +import org.jiemamy.entity.io.gen.model.EntityModelFactory; +import org.jiemamy.utils.ClassUtil; + +/** + * {@link EntityModelFactory}の実装クラス。 + * + * @author j5ik2o + */ +public class EntityModelFactoryImpl implements EntityModelFactory { + + /** パッケージ名、デフォルトパッケージの場合は{@code null} */ + protected String packageName; + + /** 属性モデルのファクトリ */ + protected AttributeModelFactory attributeModelFactory; + + /** 関連モデルのファクトリ */ + protected AssociationModelFactory associationModelFactory; + + /** 複合一意制約モデルのファクトリ */ + protected CompositeUniqueConstraintModelFactory compositeUniqueConstraintModelFactory; + + /** エンティティクラスでアクセサを使用する場合 {@code true} */ + protected boolean useAccessor; + + /** コメントを使用する場合{@code true} */ + protected boolean useComment; + + /** カタログ名を表示する場合{@code true} */ + protected boolean showCatalogName; + + /** スキーマ名を表示する場合{@code true} */ + protected boolean showSchemaName; + + /** テーブル名を表示する場合{@code true} */ + protected boolean showTableName; + + /** エンティティのスーパークラス、スーパークラスを持たない場合は{@code null} */ + protected Class<?> superclass; + + /** クラスモデルのサポート */ + protected ClassModelSupport classModelSupport = new ClassModelSupport(); + + /** 生成モデルのサポート */ + protected GeneratedModelSupport generatedModelSupport = new GeneratedModelSupport(); + + + /** + * インスタンスを生成する。 + * + * @param packageName パッケージ名、デフォルトパッケージの場合は{@code null} + * @param superclass エンティティのスーパークラス、スーパークラスを持たない場合は{@code null} + * @param attributeModelFactory 属性モデルのファクトリ + * @param associationModelFactory 関連モデルのファクトリ + * @param compositeUniqueConstraintModelFactory 複合一意制約モデルのファクトリ + * @param useAccessor エンティティクラスでアクセサを使用する場合 {@code true} + * @param useComment コメントを使用する場合{@code true} + * @param showCatalogName カタログ名を表示する場合{@code true} + * @param showSchemaName スキーマ名を表示する場合{@code true} + * @param showTableName テーブル名を表示する場合{@code true} + */ + public EntityModelFactoryImpl(String packageName, Class<?> superclass, AttributeModelFactory attributeModelFactory, + AssociationModelFactory associationModelFactory, + CompositeUniqueConstraintModelFactory compositeUniqueConstraintModelFactory, boolean useAccessor, + boolean useComment, boolean showCatalogName, boolean showSchemaName, boolean showTableName) { + if (attributeModelFactory == null) { + throw new NullPointerException("attributeModelFactory"); + } + if (associationModelFactory == null) { + throw new NullPointerException("associationModelFactory"); + } + if (compositeUniqueConstraintModelFactory == null) { + throw new NullPointerException("compositeUniqueConstraintModelFactory"); + } + this.packageName = packageName; + this.superclass = superclass; + this.attributeModelFactory = attributeModelFactory; + this.associationModelFactory = associationModelFactory; + this.compositeUniqueConstraintModelFactory = compositeUniqueConstraintModelFactory; + this.useAccessor = useAccessor; + this.useComment = useComment; + this.showCatalogName = showCatalogName; + this.showSchemaName = showSchemaName; + this.showTableName = showTableName; +// if (superclass != null) { +// if (superclass.isAnnotationPresent(MappedSuperclass.class)) { +// mappedSuperclassBeanDesc = BeanDescFactory.getBeanDesc(superclass); +// } +// } + } + + /** + * 関連モデルを処理する。 + * + * @param entityModel エンティティモデル + * @param entityDesc エンティティ記述 + */ + protected void doAssociationModel(EntityModel entityModel, EntityDesc entityDesc) { + for (AssociationDesc associationDesc : entityDesc.getAssociationDescList()) { + if (superclass != null && ClassUtil.getFieldNoException(superclass, associationDesc.getName()) != null) { + continue; + } + AssociationModel associationModel = associationModelFactory.getAssociationModel(associationDesc); + entityModel.addAssociationModel(associationModel); + } + } + + /** + * 属性モデルを処理する。 + * + * @param entityModel エンティティモデル + * @param entityDesc エンティティ記述 + */ + protected void doAttributeModel(EntityModel entityModel, EntityDesc entityDesc) { + for (AttributeDesc attributeDesc : entityDesc.getAttributeDescList()) { + if (superclass != null && ClassUtil.getFieldNoException(superclass, attributeDesc.getName()) != null) { + continue; + } + AttributeModel attributeModel = attributeModelFactory.getAttributeModel(attributeDesc); + entityModel.addAttributeModel(attributeModel); + } + } + + /** + * 複合一意制約モデルを処理する。 + * + * @param entityModel エンティティモデル + * @param entityDesc エンティティ記述 + */ + protected void doCompositeUniqueConstraintModel(EntityModel entityModel, EntityDesc entityDesc) { + for (CompositeUniqueConstraintDesc compositeUniqueConstraintDesc : entityDesc + .getCompositeUniqueConstraintDescList()) { + CompositeUniqueConstraintModel compositeUniqueConstraintModel = + compositeUniqueConstraintModelFactory.getUniqueConstraintModel(compositeUniqueConstraintDesc); + entityModel.addCompositeUniqueConstraintModel(compositeUniqueConstraintModel); + } + } + + /** + * 生成情報を処理する。 + * + * @param entityModel エンティティモデル + * @param entityDesc エンティティ記述 + */ + protected void doGeneratedInfo(EntityModel entityModel, EntityDesc entityDesc) { + generatedModelSupport.fillGeneratedInfo(this, entityModel); + } + + /** + * インポート名を処理する。 + * + * @param model エンティティクラスのモデル + * @param entityDesc エンティティ記述 + */ + protected void doImportName(EntityModel model, EntityDesc entityDesc) { + classModelSupport.addImportName(model, Entity.class); + classModelSupport.addImportName(model, Serializable.class); + classModelSupport.addImportName(model, Generated.class); + if (model.getCatalogName() != null || model.getSchemaName() != null || model.getTableName() != null) { + classModelSupport.addImportName(model, Table.class); + } + if (superclass != null) { + classModelSupport.addImportName(model, superclass); + } + for (AttributeModel attr : model.getAttributeModelList()) { + if (attr.isId()) { + classModelSupport.addImportName(model, Id.class); + if (attr.getGenerationType() != null) { + classModelSupport.addImportName(model, GeneratedValue.class); + classModelSupport.addImportName(model, GenerationType.class); + if (attr.getGenerationType() == GenerationType.SEQUENCE) { + classModelSupport.addImportName(model, SequenceGenerator.class); + } else if (attr.getGenerationType() == GenerationType.TABLE) { + classModelSupport.addImportName(model, TableGenerator.class); + } + } + } + if (attr.isLob()) { + classModelSupport.addImportName(model, Lob.class); + } + if (attr.getTemporalType() != null) { + classModelSupport.addImportName(model, Temporal.class); + classModelSupport.addImportName(model, TemporalType.class); + } + if (attr.isTransient()) { + classModelSupport.addImportName(model, Transient.class); + } else { + classModelSupport.addImportName(model, Column.class); + } + if (attr.isVersion()) { + classModelSupport.addImportName(model, Version.class); + } + classModelSupport.addImportName(model, attr.getAttributeClass()); + } + for (AssociationModel asso : model.getAssociationModelList()) { + AssociationType associationType = asso.getAssociationType(); + if (associationType == AssociationType.ONE_TO_MANY) { + classModelSupport.addImportName(model, List.class); + } + classModelSupport.addImportName(model, associationType.getAnnotation()); + if (asso.getJoinColumnModel() != null) { + classModelSupport.addImportName(model, JoinColumn.class); + } + if (asso.getJoinColumnsModel() != null) { + classModelSupport.addImportName(model, JoinColumn.class); + classModelSupport.addImportName(model, JoinColumns.class); + } + } + if (!model.getCompositeUniqueConstraintModelList().isEmpty()) { + classModelSupport.addImportName(model, Table.class); + classModelSupport.addImportName(model, UniqueConstraint.class); + } + } + + public EntityModel getEntityModel(EntityDesc entityDesc) { + EntityModel entityModel = new EntityModel(); + if (showCatalogName) { + entityModel.setCatalogName(entityDesc.getCatalogName()); + } + if (showSchemaName) { + entityModel.setSchemaName(entityDesc.getSchemaName()); + } + if (showTableName) { + entityModel.setTableName(entityDesc.getTableName()); + } + entityModel.setPackageName(packageName); + entityModel.setShortClassName(entityDesc.getName()); + if (superclass != null) { + entityModel.setShortSuperclassName(superclass.getSimpleName()); + } + entityModel.setCompositeId(entityDesc.hasCompositeId()); + entityModel.setUseAccessor(useAccessor); + entityModel.setComment(entityDesc.getComment()); + entityModel.setUseComment(useComment); + doAttributeModel(entityModel, entityDesc); + doAssociationModel(entityModel, entityDesc); + doCompositeUniqueConstraintModel(entityModel, entityDesc); + doImportName(entityModel, entityDesc); + doGeneratedInfo(entityModel, entityDesc); + return entityModel; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/EntityModelFactoryImpl.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/GeneratedModelSupport.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/GeneratedModelSupport.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/GeneratedModelSupport.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,42 +1,42 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.model.impl; - -import org.jiemamy.entity.io.ProductInfo; -import org.jiemamy.entity.io.gen.model.GeneratedModel; - -/** - * {@link GeneratedModel}のサポートクラス。 - * - * @author j5ik2o - */ -public class GeneratedModelSupport { - - /** - * 生成情報を設定する。 - * - * @param modelFactory モデルを作成したファクトリ - * @param model 生成されるモデル - */ - public void fillGeneratedInfo(Object modelFactory, GeneratedModel model) { - ProductInfo productInfo = ProductInfo.getInstance(); - model.addGeneratedInfo(productInfo.getName() + " " + productInfo.getVersion()); - model.addGeneratedInfo(modelFactory.getClass().getName()); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.model.impl; + +import org.jiemamy.entity.io.ProductInfo; +import org.jiemamy.entity.io.gen.model.GeneratedModel; + +/** + * {@link GeneratedModel}のサポートクラス。 + * + * @author j5ik2o + */ +public class GeneratedModelSupport { + + /** + * 生成情報を設定する。 + * + * @param modelFactory モデルを作成したファクトリ + * @param model 生成されるモデル + */ + public void fillGeneratedInfo(Object modelFactory, GeneratedModel model) { + ProductInfo productInfo = ProductInfo.getInstance(); + model.addGeneratedInfo(productInfo.getName() + " " + productInfo.getVersion()); + model.addGeneratedInfo(modelFactory.getClass().getName()); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/model/impl/GeneratedModelSupport.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/CannotCreatePropertyException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/CannotCreatePropertyException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/CannotCreatePropertyException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,38 +1,38 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -/** - * プロパティを生成できなかった場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class CannotCreatePropertyException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param t {@link Throwable} - */ - public CannotCreatePropertyException(Throwable t) { - super(t); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +/** + * プロパティを生成できなかった場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class CannotCreatePropertyException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param t {@link Throwable} + */ + public CannotCreatePropertyException(Throwable t) { + super(t); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/CannotCreatePropertyException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnDuplicatedException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnDuplicatedException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnDuplicatedException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,43 +1,43 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 5, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -/** - * カラムが重複した場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class ColumnDuplicatedException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName オリジナルのプロパティ名 - * @param propertyName2 対象のプロパティ名 - * @param columnName カラム名 - */ - public ColumnDuplicatedException(String entityName, String propertyName, String propertyName2, String columnName) { - super(String.format("Duplicated column." - + "(entityName = %s, originalPropertyName = %s, targetPropertyName = %s, columnName = %s)", entityName, - propertyName, propertyName2, columnName)); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 5, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +/** + * カラムが重複した場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class ColumnDuplicatedException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName オリジナルのプロパティ名 + * @param propertyName2 対象のプロパティ名 + * @param columnName カラム名 + */ + public ColumnDuplicatedException(String entityName, String propertyName, String propertyName2, String columnName) { + super(String.format("Duplicated column." + + "(entityName = %s, originalPropertyName = %s, targetPropertyName = %s, columnName = %s)", entityName, + propertyName, propertyName2, columnName)); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnDuplicatedException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,200 +1,200 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 3, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -import org.apache.commons.lang.builder.ToStringBuilder; - -/** - * カラム用のメタデータです。 - * - * @author j5ik2o - */ -public class ColumnMeta { - - /** 名前 */ - private String name; - - private String logicalName; - - /** 挿入可能フラグ */ - private boolean insertable = true; - - /** 更新可能フラグ */ - private boolean updatable = true; - - /** NULL許可制約 */ - private boolean nullable = true; - - /** ユニーク制約 */ - private boolean unique = false; - - private Integer length; - - private Integer precision; - - - /** - * カラムのサイズを取得する。 - * - * @return カラムのサイズ - */ - public Integer getLength() { - return length; - } - - /** - * 論理名を取得する。 - * - * @return 論理名 - */ - public String getLogicalName() { - return logicalName; - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return name; - } - - /** - * 精度を取得する。 - * - * @return 精度 - */ - public Integer getPrecision() { - return precision; - } - - /** - * 挿入可能フラグを取得する。 - * - * @return trueの場合は挿入可能 - */ - public boolean isInsertable() { - return insertable; - } - - /** - * NULL許可制約を取得する。 - * - * @return NULL許可制約 - */ - public boolean isNullable() { - return nullable; - } - - /** - * ユニーク制約を取得する。 - * - * @return ユニーク制約 - */ - public boolean isUnique() { - return unique; - } - - /** - * 更新可能フラグを取得する。 - * - * @return trueの場合は更新可能 - */ - public boolean isUpdatable() { - return updatable; - } - - /** - * 挿入可能フラグを設定する。 - * - * @param insertable 挿入可能フラグ - */ - public void setInsertable(boolean insertable) { - this.insertable = insertable; - } - - /** - * カラムのサイズを設定する。 - * - * @param length カラムのサイズ - */ - public void setLength(Integer length) { - this.length = length; - } - - /** - * 論理名を設定する。 - * - * @param logicalName 論理名 - */ - public void setLogicalName(String logicalName) { - this.logicalName = logicalName; - } - - /** - * 名前を設定する。 - * - * @param name 名前 - */ - public void setName(String name) { - this.name = name; - } - - /** - * NULL許可制約を設定する。 - * - * @param nullable NULL許可制約 - */ - public void setNullable(boolean nullable) { - this.nullable = nullable; - } - - /** - * 精度を設定する。 - * - * @param precision 精度 - */ - public void setPrecision(Integer precision) { - this.precision = precision; - } - - /** - * ユニーク制約を設定する。 - * - * @param unique ユニーク制約 - */ - public void setUnique(boolean unique) { - this.unique = unique; - } - - /** - * 更新可能フラグを設定する。 - * - * @param updatable 更新可能フラグ - */ - public void setUpdatable(boolean updatable) { - this.updatable = updatable; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 3, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * カラム用のメタデータです。 + * + * @author j5ik2o + */ +public class ColumnMeta { + + /** 名前 */ + private String name; + + private String logicalName; + + /** 挿入可能フラグ */ + private boolean insertable = true; + + /** 更新可能フラグ */ + private boolean updatable = true; + + /** NULL許可制約 */ + private boolean nullable = true; + + /** ユニーク制約 */ + private boolean unique = false; + + private Integer length; + + private Integer precision; + + + /** + * カラムのサイズを取得する。 + * + * @return カラムのサイズ + */ + public Integer getLength() { + return length; + } + + /** + * 論理名を取得する。 + * + * @return 論理名 + */ + public String getLogicalName() { + return logicalName; + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return name; + } + + /** + * 精度を取得する。 + * + * @return 精度 + */ + public Integer getPrecision() { + return precision; + } + + /** + * 挿入可能フラグを取得する。 + * + * @return trueの場合は挿入可能 + */ + public boolean isInsertable() { + return insertable; + } + + /** + * NULL許可制約を取得する。 + * + * @return NULL許可制約 + */ + public boolean isNullable() { + return nullable; + } + + /** + * ユニーク制約を取得する。 + * + * @return ユニーク制約 + */ + public boolean isUnique() { + return unique; + } + + /** + * 更新可能フラグを取得する。 + * + * @return trueの場合は更新可能 + */ + public boolean isUpdatable() { + return updatable; + } + + /** + * 挿入可能フラグを設定する。 + * + * @param insertable 挿入可能フラグ + */ + public void setInsertable(boolean insertable) { + this.insertable = insertable; + } + + /** + * カラムのサイズを設定する。 + * + * @param length カラムのサイズ + */ + public void setLength(Integer length) { + this.length = length; + } + + /** + * 論理名を設定する。 + * + * @param logicalName 論理名 + */ + public void setLogicalName(String logicalName) { + this.logicalName = logicalName; + } + + /** + * 名前を設定する。 + * + * @param name 名前 + */ + public void setName(String name) { + this.name = name; + } + + /** + * NULL許可制約を設定する。 + * + * @param nullable NULL許可制約 + */ + public void setNullable(boolean nullable) { + this.nullable = nullable; + } + + /** + * 精度を設定する。 + * + * @param precision 精度 + */ + public void setPrecision(Integer precision) { + this.precision = precision; + } + + /** + * ユニーク制約を設定する。 + * + * @param unique ユニーク制約 + */ + public void setUnique(boolean unique) { + this.unique = unique; + } + + /** + * 更新可能フラグを設定する。 + * + * @param updatable 更新可能フラグ + */ + public void setUpdatable(boolean updatable) { + this.updatable = updatable; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnMetaFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnMetaFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnMetaFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,40 +1,40 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 5, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -import java.lang.reflect.Field; - -/** - * {@link ColumnMeta}のファクトリインターフェイス。 - * - * @author j5ik2o - */ -public interface ColumnMetaFactory { - - /** - * {@link ColumnMeta}を生成する。 - * - * @param field フィールド - * @param entityMeta {@link EntityMeta} - * @param propertyMeta {@link PropertyMeta} - * @return {@link ColumnMeta} - */ - ColumnMeta createColumnMeta(Field field, EntityMeta entityMeta, PropertyMeta propertyMeta); - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 5, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +import java.lang.reflect.Field; + +/** + * {@link ColumnMeta}のファクトリインターフェイス。 + * + * @author j5ik2o + */ +public interface ColumnMetaFactory { + + /** + * {@link ColumnMeta}を生成する。 + * + * @param field フィールド + * @param entityMeta {@link EntityMeta} + * @param propertyMeta {@link PropertyMeta} + * @return {@link ColumnMeta} + */ + ColumnMeta createColumnMeta(Field field, EntityMeta entityMeta, PropertyMeta propertyMeta); + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/ColumnMetaFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityMetaReaderContext.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityMetaReaderContext.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityMetaReaderContext.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,162 +1,162 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 3, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -import java.io.File; -import java.util.List; -import java.util.regex.Pattern; - -import org.apache.commons.lang.builder.ToStringBuilder; - -import org.jiemamy.utils.CollectionsUtil; - -/** - * {@link EntityMetaReader}のコンテキストクラス。 - * - * @author j5ik2o - */ -public class DefaultEntityMetaReaderContext implements EntityMetaReaderContext { - - private List<File> classPathDirs; - - private String packageName; - - private EntityMetaFactory entityMetaFactory; - - private List<Pattern> shortClassNamePatterns = CollectionsUtil.newArrayList(); - - private List<Pattern> ignoreShortClassNamePatterns = CollectionsUtil.newArrayList(); - - private boolean readComment; - - private List<File> javaSrcFileDirs; - - private String javaFileEncoding; - - - public List<File> getClassPathDirs() { - return classPathDirs; - } - - public EntityMetaFactory getEntityMetaFactory() { - return entityMetaFactory; - } - - public List<Pattern> getIgnoreShortClassNamePatterns() { - return ignoreShortClassNamePatterns; - } - - public String getJavaFileEncoding() { - return javaFileEncoding; - } - - public List<File> getJavaSrcFileDirs() { - return javaSrcFileDirs; - } - - public String getPackageName() { - return packageName; - } - - public List<Pattern> getShortClassNamePatterns() { - return shortClassNamePatterns; - } - - public boolean isReadComment() { - return readComment; - } - - /** - * クラスパスのリストを設定する。 - * - * @param classPathDirs クラスパスのリスト - */ - public void setClassPathDirs(List<File> classPathDirs) { - this.classPathDirs = classPathDirs; - } - - /** - * {@link EntityMetaFactory}を設定する。 - * - * @param entityMetaFactory {@link EntityMetaFactory} - */ - public void setEntityMetaFactory(EntityMetaFactory entityMetaFactory) { - this.entityMetaFactory = entityMetaFactory; - } - - /** - * 無視する短いクラス名のパターンのリストを設定する。 - * - * @param ignoreShortClassNamePatterns 無視する短いクラス名のパターンのリスト - */ - public void setIgnoreShortClassNamePatterns(List<Pattern> ignoreShortClassNamePatterns) { - this.ignoreShortClassNamePatterns = ignoreShortClassNamePatterns; - } - - /** - * Javaファイルのエンコーディングを設定する。 - * - * @param javaFileEncoding Javaファイルのエンコーディング - */ - public void setJavaFileEncoding(String javaFileEncoding) { - this.javaFileEncoding = javaFileEncoding; - } - - /** - * Javaソースファイルのディレクトリのリストを設定する。 - * - * @param javaFileSrcDirs Javaソースファイルのディレクトリのリスト - */ - public void setJavaSrcFileDirs(List<File> javaFileSrcDirs) { - javaSrcFileDirs = javaFileSrcDirs; - } - - /** - * パッケージ名を設定する。 - * - * @param packageName パッケージ名 - */ - public void setPackageName(String packageName) { - this.packageName = packageName; - } - - /** - * コメントを処理するかどうかのフラグを設定する。 - * - * @param readComment コメント処理フラグ - */ - public void setReadComment(boolean readComment) { - this.readComment = readComment; - } - - /** - * 短いクラス名のパターンのリストを取得する。 - * - * @param shortClassNamePatterns 短いクラス名のパターンのリストを - */ - public void setShortClassNamePatterns(List<Pattern> shortClassNamePatterns) { - this.shortClassNamePatterns = shortClassNamePatterns; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 3, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +import java.io.File; +import java.util.List; +import java.util.regex.Pattern; + +import org.apache.commons.lang.builder.ToStringBuilder; + +import org.jiemamy.utils.CollectionsUtil; + +/** + * {@link EntityMetaReader}のコンテキストクラス。 + * + * @author j5ik2o + */ +public class DefaultEntityMetaReaderContext implements EntityMetaReaderContext { + + private List<File> classPathDirs; + + private String packageName; + + private EntityMetaFactory entityMetaFactory; + + private List<Pattern> shortClassNamePatterns = CollectionsUtil.newArrayList(); + + private List<Pattern> ignoreShortClassNamePatterns = CollectionsUtil.newArrayList(); + + private boolean readComment; + + private List<File> javaSrcFileDirs; + + private String javaFileEncoding; + + + public List<File> getClassPathDirs() { + return classPathDirs; + } + + public EntityMetaFactory getEntityMetaFactory() { + return entityMetaFactory; + } + + public List<Pattern> getIgnoreShortClassNamePatterns() { + return ignoreShortClassNamePatterns; + } + + public String getJavaFileEncoding() { + return javaFileEncoding; + } + + public List<File> getJavaSrcFileDirs() { + return javaSrcFileDirs; + } + + public String getPackageName() { + return packageName; + } + + public List<Pattern> getShortClassNamePatterns() { + return shortClassNamePatterns; + } + + public boolean isReadComment() { + return readComment; + } + + /** + * クラスパスのリストを設定する。 + * + * @param classPathDirs クラスパスのリスト + */ + public void setClassPathDirs(List<File> classPathDirs) { + this.classPathDirs = classPathDirs; + } + + /** + * {@link EntityMetaFactory}を設定する。 + * + * @param entityMetaFactory {@link EntityMetaFactory} + */ + public void setEntityMetaFactory(EntityMetaFactory entityMetaFactory) { + this.entityMetaFactory = entityMetaFactory; + } + + /** + * 無視する短いクラス名のパターンのリストを設定する。 + * + * @param ignoreShortClassNamePatterns 無視する短いクラス名のパターンのリスト + */ + public void setIgnoreShortClassNamePatterns(List<Pattern> ignoreShortClassNamePatterns) { + this.ignoreShortClassNamePatterns = ignoreShortClassNamePatterns; + } + + /** + * Javaファイルのエンコーディングを設定する。 + * + * @param javaFileEncoding Javaファイルのエンコーディング + */ + public void setJavaFileEncoding(String javaFileEncoding) { + this.javaFileEncoding = javaFileEncoding; + } + + /** + * Javaソースファイルのディレクトリのリストを設定する。 + * + * @param javaFileSrcDirs Javaソースファイルのディレクトリのリスト + */ + public void setJavaSrcFileDirs(List<File> javaFileSrcDirs) { + javaSrcFileDirs = javaFileSrcDirs; + } + + /** + * パッケージ名を設定する。 + * + * @param packageName パッケージ名 + */ + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + /** + * コメントを処理するかどうかのフラグを設定する。 + * + * @param readComment コメント処理フラグ + */ + public void setReadComment(boolean readComment) { + this.readComment = readComment; + } + + /** + * 短いクラス名のパターンのリストを取得する。 + * + * @param shortClassNamePatterns 短いクラス名のパターンのリストを + */ + public void setShortClassNamePatterns(List<Pattern> shortClassNamePatterns) { + this.shortClassNamePatterns = shortClassNamePatterns; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityMetaReaderContext.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityMetaReaderFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityMetaReaderFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityMetaReaderFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,34 +1,34 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 10, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -import org.jiemamy.entity.io.meta.impl.EntityMetaReaderImpl; - -/** - * {@link EntityMetaReaderFactory}の実装クラス。 - * - * @author j5ik2o - */ -public class DefaultEntityMetaReaderFactory implements EntityMetaReaderFactory { - - public EntityMetaReader createEntityMetaReader(EntityMetaReaderContext entityMetaReaderContext) { - return new EntityMetaReaderImpl(entityMetaReaderContext); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 10, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +import org.jiemamy.entity.io.meta.impl.EntityMetaReaderImpl; + +/** + * {@link EntityMetaReaderFactory}の実装クラス。 + * + * @author j5ik2o + */ +public class DefaultEntityMetaReaderFactory implements EntityMetaReaderFactory { + + public EntityMetaReader createEntityMetaReader(EntityMetaReaderContext entityMetaReaderContext) { + return new EntityMetaReaderImpl(entityMetaReaderContext); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityMetaReaderFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityClassNotFoundException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityClassNotFoundException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityClassNotFoundException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,64 +1,64 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 4, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -/** - * エンティティクラスが見つからなかった場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class EntityClassNotFoundException extends Exception { - - /** - * インスタンスを生成する。 - */ - public EntityClassNotFoundException() { - super(); - } - - /** - * インスタンスを生成する。 - * - * @param message メッセージ - */ - public EntityClassNotFoundException(String message) { - super(message); - } - - /** - * インスタンスを生成する。 - * - * @param message メッセージ - * @param cause 原因 - */ - public EntityClassNotFoundException(String message, Throwable cause) { - super(message, cause); - } - - /** - * インスタンスを生成する。 - * - * @param cause 原因 - */ - public EntityClassNotFoundException(Throwable cause) { - super(cause); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 4, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +/** + * エンティティクラスが見つからなかった場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class EntityClassNotFoundException extends Exception { + + /** + * インスタンスを生成する。 + */ + public EntityClassNotFoundException() { + super(); + } + + /** + * インスタンスを生成する。 + * + * @param message メッセージ + */ + public EntityClassNotFoundException(String message) { + super(message); + } + + /** + * インスタンスを生成する。 + * + * @param message メッセージ + * @param cause 原因 + */ + public EntityClassNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + /** + * インスタンスを生成する。 + * + * @param cause 原因 + */ + public EntityClassNotFoundException(Throwable cause) { + super(cause); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityClassNotFoundException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityColumnNotFoundException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityColumnNotFoundException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityColumnNotFoundException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,38 +1,38 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -/** - * カラムが見つからなかった場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class EntityColumnNotFoundException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param columnName カラム名 - */ - public EntityColumnNotFoundException(String entityName, String columnName) { - super(String.format("Column not found.(entityName = %s, columnName = %s)", entityName, columnName)); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +/** + * カラムが見つからなかった場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class EntityColumnNotFoundException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param columnName カラム名 + */ + public EntityColumnNotFoundException(String entityName, String columnName) { + super(String.format("Column not found.(entityName = %s, columnName = %s)", entityName, columnName)); + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityColumnNotFoundException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,393 +1,393 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 3, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang.builder.ToStringBuilder; - -import org.jiemamy.utils.ArrayMap; -import org.jiemamy.utils.CollectionsUtil; -import org.jiemamy.utils.PropertyNotFoundException; - -/** - * JPA用のエンティティメタデータクラス。 - * - * @author j5ik2o - */ -public class EntityMeta { - - /** エンティティクラス */ - private Class<?> entityClass; - - /** エンティティ名 */ - private String name; - - /** テーブルメタデータ */ - private TableMeta tableMeta; - - /** IDプロパティメタデータのリスト */ - private List<PropertyMeta> idPropertyMetas = CollectionsUtil.newArrayList(); - - /** プロパティ名に関連するプロパティメタデータのマップ */ - private ArrayMap<String, PropertyMeta> propertyMetas = new ArrayMap<String, PropertyMeta>(); - - /** バージョンのプロパティメタデータ */ - private PropertyMeta versionPropertyMeta; - - /** カラム名に関連するプロパティメタデータのマップ */ - private ArrayMap<String, PropertyMeta> columnPropertyMetas = new ArrayMap<String, PropertyMeta>(); - - /** mappedBy属性に関連するプロパティメタデータのマップ */ - private Map<String, Map<String, PropertyMeta>> mappedByPropertyMetas = CollectionsUtil.newHashMap(); - - /** 追加情報 */ - private Map<String, Object> additionalInfo = CollectionsUtil.newHashMap(); - - - /** - * 追加情報を追加する。 - * - * @param <T> 値の型 - * @param key キー - * @param value 値 - */ - public <T>void addAdditionalInfo(String key, T value) { - additionalInfo.put(key, value); - } - - /** - * {@link PropertyMeta}を追加する。 - * - * @param propertyMeta {@link PropertyMeta} - * @throws ColumnDuplicatedException カラムがだぶって生成された場合 - * @throws PropertyDuplicatedException プロパティがだぶって生成された場合 - */ - public void addPropertyMeta(PropertyMeta propertyMeta) throws ColumnDuplicatedException, - PropertyDuplicatedException { - if (propertyMetas.put(propertyMeta.getName(), propertyMeta) != null) { - throw new PropertyDuplicatedException(name, propertyMeta.getName()); - } - if (propertyMeta.isId()) { - idPropertyMetas.add(propertyMeta); - } - if (propertyMeta.isVersion()) { - versionPropertyMeta = propertyMeta; - } - if (propertyMeta.getMappedBy() != null) { - Map<String, PropertyMeta> m = mappedByPropertyMetas.get(propertyMeta.getMappedBy()); - if (m == null) { - m = CollectionsUtil.newHashMap(); - mappedByPropertyMetas.put(propertyMeta.getMappedBy(), m); - } - m.put(propertyMeta.getRelationshipClass().getName(), propertyMeta); - } - if (propertyMeta.getColumnMeta() != null) { - String columnName = propertyMeta.getColumnMeta().getName(); - PropertyMeta pm2 = columnPropertyMetas.put(columnName, propertyMeta); - if (pm2 != null) { - throw new ColumnDuplicatedException(name, pm2.getName(), propertyMeta.getName(), columnName); - } - } - - } - - /** - * 追加情報を取得する。 - * - * @param <T> 値の型 - * @param key キー - * @return 値 - */ - @SuppressWarnings("unchecked") - public <T>T getAdditionalInfo(String key) { - return (T) additionalInfo.get(key); - } - - /** - * カラムに結びつく全てのプロパティメタデータの{@link Iterable}を取得する。 - * - * @return カラムに結びつく全てのプロパティメタデータの{@link Iterable} - */ - public Iterable<PropertyMeta> getAllColumnPropertyMeta() { - return new Iterable<PropertyMeta>() { - - public Iterator<PropertyMeta> iterator() { - return new Iterator<PropertyMeta>() { - - private int i; - - - public boolean hasNext() { - return i < columnPropertyMetas.size(); - } - - public PropertyMeta next() { - return columnPropertyMetas.get(i++); - } - - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - }; - } - - /** - * 全てのプロパティメタデータの{@link Iterable}を取得する。 - * - * @return 全てのプロパティメタデータの{@link Iterable} - */ - public Iterable<PropertyMeta> getAllPropertyMeta() { - return new Iterable<PropertyMeta>() { - - public Iterator<PropertyMeta> iterator() { - return new Iterator<PropertyMeta>() { - - private int i; - - - public boolean hasNext() { - return i < propertyMetas.size(); - } - - public PropertyMeta next() { - return propertyMetas.get(i++); - } - - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - }; - } - - /** - * カラムに結びつくプロパティメタデータを取得する。 - * - * @param index カラムインデックス - * @return プロパティメタデータ - */ - public PropertyMeta getColumnPropertyMeta(int index) { - return columnPropertyMetas.get(index); - } - - /** - * カラムに結びつくプロパティメタデータを取得する。 - * - * @param columnName カラム名 - * @return プロパティメタデータ - * @throws EntityColumnNotFoundException カラム用のプロパティメタデータが見つからない場合 - * - */ - public PropertyMeta getColumnPropertyMeta(String columnName) throws EntityColumnNotFoundException { - PropertyMeta meta = columnPropertyMetas.get(columnName); - if (meta == null) { - throw new EntityColumnNotFoundException(name, columnName); - } - return meta; - } - - /** - * エンンティクラスを取得する。 - * - * @return エンティティクラス - */ - public Class<?> getEntityClass() { - return entityClass; - } - - /** - * IDプロパティメタのリストを取得する。 - * - * @return IDプロパティメタのリスト - */ - public List<PropertyMeta> getIdPropertyMetas() { - return idPropertyMetas; - } - - /** - * MappedByで注釈されているプロパティメタデータを取得する。 - * - * @param mappedBy 関連の所有者側のプロパティ名 - * @param relationshipClass 関連クラス - * @return MappedByで注釈されているプロパティメタデータ - */ - public PropertyMeta getMappedByPropertyMeta(String mappedBy, Class<?> relationshipClass) { - Map<String, PropertyMeta> m = mappedByPropertyMetas.get(mappedBy); - if (m == null) { - return null; - } - return m.get(relationshipClass.getName()); - } - - /** - * エンティティ名を取得する。 - * - * @return エンティティ名 - */ - public String getName() { - return name; - } - - /** - * プロパティメタデータを取得する。 - * - * @param index インデックス - * @return プロパティメタデータ - */ - public PropertyMeta getPropertyMeta(int index) { - return propertyMetas.get(index); - } - - /** - * プロパティメタデータを取得する。 - * - * @param propertyName プロパティ名 - * @return {@link PropertyMeta} - * @throws PropertyNotFoundException プロパティがみつからなかった場合 - */ - public PropertyMeta getPropertyMeta(String propertyName) throws PropertyNotFoundException { - PropertyMeta meta = propertyMetas.get(propertyName); - if (meta == null) { - throw new PropertyNotFoundException(name, propertyName); - } - return meta; - } - - /** - * プロパティメタデータの数を取得する。 - * - * @return プロパティメタデータの数 - */ - public int getPropertyMetaSize() { - return propertyMetas.size(); - } - - /** - * テーブルメタデータを取得する。 - * - * @return {@link TableMeta} - */ - public TableMeta getTableMeta() { - return tableMeta; - } - - /** - * バージョン用プロパティメタデータを取得する。 - * - * @return バージョン用プロパティメタデータ - */ - public PropertyMeta getVersionPropertyMeta() { - return versionPropertyMeta; - } - - /** - * カラムに結びつくプロパティメタデータがあるかどうかを取得する。 - * - * @param columnName カラム名 - * @return プロパティメタデータがあるかどうか - */ - public boolean hasColumnPropertyMeta(String columnName) { - return columnPropertyMetas.containsKey(columnName); - } - - /** - * プロパティメタデータの有無を取得する。 - * - * @param propertyName プロパティ名 - * @return trueの場合は存在する - */ - public boolean hasPropertyMeta(String propertyName) { - return propertyMetas.containsKey(propertyName); - } - - /** - * バージョンを表すプロパティメタデータがあれば<code>true</code>を取得する。 - * - * @return バージョンを表すプロパティメタデータがあれば<code>true</code> - */ - public boolean hasVersionPropertyMeta() { - return versionPropertyMeta != null; - } - - /** - * エンティティクラスを設定する。 - * - * @param entityClass エンティティクラス - */ - public void setEntityClass(Class<?> entityClass) { - this.entityClass = entityClass; - } - - /** - * IDプロパティメタのリストを設定する。 - * - * @param idPropertyMetas IDプロパティメタのリスト - */ - public void setIdPropertyMetas(List<PropertyMeta> idPropertyMetas) { - this.idPropertyMetas = idPropertyMetas; - } - - /** - * エンティティ名を設定する。 - * - * @param name エンティティ名 - */ - public void setName(String name) { - this.name = name; - } - - /** - * プロパティメタデータを設定する。 - * - * @param propertyMetas プロパティメタ - */ - public void setPropertyMetaMap(ArrayMap<String, PropertyMeta> propertyMetas) { - this.propertyMetas = propertyMetas; - } - - /** - * テーブルメタデータを設定する。 - * - * @param tableMeta {@link TableMeta} - */ - public void setTableMeta(TableMeta tableMeta) { - this.tableMeta = tableMeta; - } - - /** - * バージョン用プロパティメタデータを設定する。 - * - * @param versionPropertyMeta バージョン用プロパティメタデータ - */ - public void setVersionPropertyMeta(PropertyMeta versionPropertyMeta) { - this.versionPropertyMeta = versionPropertyMeta; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 3, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang.builder.ToStringBuilder; + +import org.jiemamy.utils.ArrayMap; +import org.jiemamy.utils.CollectionsUtil; +import org.jiemamy.utils.PropertyNotFoundException; + +/** + * JPA用のエンティティメタデータクラス。 + * + * @author j5ik2o + */ +public class EntityMeta { + + /** エンティティクラス */ + private Class<?> entityClass; + + /** エンティティ名 */ + private String name; + + /** テーブルメタデータ */ + private TableMeta tableMeta; + + /** IDプロパティメタデータのリスト */ + private List<PropertyMeta> idPropertyMetas = CollectionsUtil.newArrayList(); + + /** プロパティ名に関連するプロパティメタデータのマップ */ + private ArrayMap<String, PropertyMeta> propertyMetas = new ArrayMap<String, PropertyMeta>(); + + /** バージョンのプロパティメタデータ */ + private PropertyMeta versionPropertyMeta; + + /** カラム名に関連するプロパティメタデータのマップ */ + private ArrayMap<String, PropertyMeta> columnPropertyMetas = new ArrayMap<String, PropertyMeta>(); + + /** mappedBy属性に関連するプロパティメタデータのマップ */ + private Map<String, Map<String, PropertyMeta>> mappedByPropertyMetas = CollectionsUtil.newHashMap(); + + /** 追加情報 */ + private Map<String, Object> additionalInfo = CollectionsUtil.newHashMap(); + + + /** + * 追加情報を追加する。 + * + * @param <T> 値の型 + * @param key キー + * @param value 値 + */ + public <T>void addAdditionalInfo(String key, T value) { + additionalInfo.put(key, value); + } + + /** + * {@link PropertyMeta}を追加する。 + * + * @param propertyMeta {@link PropertyMeta} + * @throws ColumnDuplicatedException カラムがだぶって生成された場合 + * @throws PropertyDuplicatedException プロパティがだぶって生成された場合 + */ + public void addPropertyMeta(PropertyMeta propertyMeta) throws ColumnDuplicatedException, + PropertyDuplicatedException { + if (propertyMetas.put(propertyMeta.getName(), propertyMeta) != null) { + throw new PropertyDuplicatedException(name, propertyMeta.getName()); + } + if (propertyMeta.isId()) { + idPropertyMetas.add(propertyMeta); + } + if (propertyMeta.isVersion()) { + versionPropertyMeta = propertyMeta; + } + if (propertyMeta.getMappedBy() != null) { + Map<String, PropertyMeta> m = mappedByPropertyMetas.get(propertyMeta.getMappedBy()); + if (m == null) { + m = CollectionsUtil.newHashMap(); + mappedByPropertyMetas.put(propertyMeta.getMappedBy(), m); + } + m.put(propertyMeta.getRelationshipClass().getName(), propertyMeta); + } + if (propertyMeta.getColumnMeta() != null) { + String columnName = propertyMeta.getColumnMeta().getName(); + PropertyMeta pm2 = columnPropertyMetas.put(columnName, propertyMeta); + if (pm2 != null) { + throw new ColumnDuplicatedException(name, pm2.getName(), propertyMeta.getName(), columnName); + } + } + + } + + /** + * 追加情報を取得する。 + * + * @param <T> 値の型 + * @param key キー + * @return 値 + */ + @SuppressWarnings("unchecked") + public <T>T getAdditionalInfo(String key) { + return (T) additionalInfo.get(key); + } + + /** + * カラムに結びつく全てのプロパティメタデータの{@link Iterable}を取得する。 + * + * @return カラムに結びつく全てのプロパティメタデータの{@link Iterable} + */ + public Iterable<PropertyMeta> getAllColumnPropertyMeta() { + return new Iterable<PropertyMeta>() { + + public Iterator<PropertyMeta> iterator() { + return new Iterator<PropertyMeta>() { + + private int i; + + + public boolean hasNext() { + return i < columnPropertyMetas.size(); + } + + public PropertyMeta next() { + return columnPropertyMetas.get(i++); + } + + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + }; + } + + /** + * 全てのプロパティメタデータの{@link Iterable}を取得する。 + * + * @return 全てのプロパティメタデータの{@link Iterable} + */ + public Iterable<PropertyMeta> getAllPropertyMeta() { + return new Iterable<PropertyMeta>() { + + public Iterator<PropertyMeta> iterator() { + return new Iterator<PropertyMeta>() { + + private int i; + + + public boolean hasNext() { + return i < propertyMetas.size(); + } + + public PropertyMeta next() { + return propertyMetas.get(i++); + } + + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + }; + } + + /** + * カラムに結びつくプロパティメタデータを取得する。 + * + * @param index カラムインデックス + * @return プロパティメタデータ + */ + public PropertyMeta getColumnPropertyMeta(int index) { + return columnPropertyMetas.get(index); + } + + /** + * カラムに結びつくプロパティメタデータを取得する。 + * + * @param columnName カラム名 + * @return プロパティメタデータ + * @throws EntityColumnNotFoundException カラム用のプロパティメタデータが見つからない場合 + * + */ + public PropertyMeta getColumnPropertyMeta(String columnName) throws EntityColumnNotFoundException { + PropertyMeta meta = columnPropertyMetas.get(columnName); + if (meta == null) { + throw new EntityColumnNotFoundException(name, columnName); + } + return meta; + } + + /** + * エンンティクラスを取得する。 + * + * @return エンティティクラス + */ + public Class<?> getEntityClass() { + return entityClass; + } + + /** + * IDプロパティメタのリストを取得する。 + * + * @return IDプロパティメタのリスト + */ + public List<PropertyMeta> getIdPropertyMetas() { + return idPropertyMetas; + } + + /** + * MappedByで注釈されているプロパティメタデータを取得する。 + * + * @param mappedBy 関連の所有者側のプロパティ名 + * @param relationshipClass 関連クラス + * @return MappedByで注釈されているプロパティメタデータ + */ + public PropertyMeta getMappedByPropertyMeta(String mappedBy, Class<?> relationshipClass) { + Map<String, PropertyMeta> m = mappedByPropertyMetas.get(mappedBy); + if (m == null) { + return null; + } + return m.get(relationshipClass.getName()); + } + + /** + * エンティティ名を取得する。 + * + * @return エンティティ名 + */ + public String getName() { + return name; + } + + /** + * プロパティメタデータを取得する。 + * + * @param index インデックス + * @return プロパティメタデータ + */ + public PropertyMeta getPropertyMeta(int index) { + return propertyMetas.get(index); + } + + /** + * プロパティメタデータを取得する。 + * + * @param propertyName プロパティ名 + * @return {@link PropertyMeta} + * @throws PropertyNotFoundException プロパティがみつからなかった場合 + */ + public PropertyMeta getPropertyMeta(String propertyName) throws PropertyNotFoundException { + PropertyMeta meta = propertyMetas.get(propertyName); + if (meta == null) { + throw new PropertyNotFoundException(name, propertyName); + } + return meta; + } + + /** + * プロパティメタデータの数を取得する。 + * + * @return プロパティメタデータの数 + */ + public int getPropertyMetaSize() { + return propertyMetas.size(); + } + + /** + * テーブルメタデータを取得する。 + * + * @return {@link TableMeta} + */ + public TableMeta getTableMeta() { + return tableMeta; + } + + /** + * バージョン用プロパティメタデータを取得する。 + * + * @return バージョン用プロパティメタデータ + */ + public PropertyMeta getVersionPropertyMeta() { + return versionPropertyMeta; + } + + /** + * カラムに結びつくプロパティメタデータがあるかどうかを取得する。 + * + * @param columnName カラム名 + * @return プロパティメタデータがあるかどうか + */ + public boolean hasColumnPropertyMeta(String columnName) { + return columnPropertyMetas.containsKey(columnName); + } + + /** + * プロパティメタデータの有無を取得する。 + * + * @param propertyName プロパティ名 + * @return trueの場合は存在する + */ + public boolean hasPropertyMeta(String propertyName) { + return propertyMetas.containsKey(propertyName); + } + + /** + * バージョンを表すプロパティメタデータがあれば<code>true</code>を取得する。 + * + * @return バージョンを表すプロパティメタデータがあれば<code>true</code> + */ + public boolean hasVersionPropertyMeta() { + return versionPropertyMeta != null; + } + + /** + * エンティティクラスを設定する。 + * + * @param entityClass エンティティクラス + */ + public void setEntityClass(Class<?> entityClass) { + this.entityClass = entityClass; + } + + /** + * IDプロパティメタのリストを設定する。 + * + * @param idPropertyMetas IDプロパティメタのリスト + */ + public void setIdPropertyMetas(List<PropertyMeta> idPropertyMetas) { + this.idPropertyMetas = idPropertyMetas; + } + + /** + * エンティティ名を設定する。 + * + * @param name エンティティ名 + */ + public void setName(String name) { + this.name = name; + } + + /** + * プロパティメタデータを設定する。 + * + * @param propertyMetas プロパティメタ + */ + public void setPropertyMetaMap(ArrayMap<String, PropertyMeta> propertyMetas) { + this.propertyMetas = propertyMetas; + } + + /** + * テーブルメタデータを設定する。 + * + * @param tableMeta {@link TableMeta} + */ + public void setTableMeta(TableMeta tableMeta) { + this.tableMeta = tableMeta; + } + + /** + * バージョン用プロパティメタデータを設定する。 + * + * @param versionPropertyMeta バージョン用プロパティメタデータ + */ + public void setVersionPropertyMeta(PropertyMeta versionPropertyMeta) { + this.versionPropertyMeta = versionPropertyMeta; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaCommand.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaCommand.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaCommand.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,37 +1,37 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 10, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -import java.util.List; - -/** - * {@link EntityMeta}を処理するためのコマンドインターフェイス。 - * - * @author j5ik2o - */ -public interface EntityMetaCommand { - - /** - * {@link EntityMeta}を処理する。 - * - * @param entityMetaList {@link EntityMeta}のリスト - */ - void execute(List<EntityMeta> entityMetaList); - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 10, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +import java.util.List; + +/** + * {@link EntityMeta}を処理するためのコマンドインターフェイス。 + * + * @author j5ik2o + */ +public interface EntityMetaCommand { + + /** + * {@link EntityMeta}を処理する。 + * + * @param entityMetaList {@link EntityMeta}のリスト + */ + void execute(List<EntityMeta> entityMetaList); + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,38 +1,38 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 3, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -import org.jiemamy.utils.Disposable; - -/** - * {@link EntityMeta}のファクトリインターフェイス - * - * @author j5ik2o - */ -public interface EntityMetaFactory extends Disposable { - - /** - * エンティティメタデータを取得する。 - * - * @param entityClass エンティティクラス - * @return {@link EntityMeta} - * @throws NonEntityException entityClassがエンティティでない場合 - */ - EntityMeta getEntityMeta(Class<?> entityClass) throws NonEntityException; -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 3, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +import org.jiemamy.utils.Disposable; + +/** + * {@link EntityMeta}のファクトリインターフェイス + * + * @author j5ik2o + */ +public interface EntityMetaFactory extends Disposable { + + /** + * エンティティメタデータを取得する。 + * + * @param entityClass エンティティクラス + * @return {@link EntityMeta} + * @throws NonEntityException entityClassがエンティティでない場合 + */ + EntityMeta getEntityMeta(Class<?> entityClass) throws NonEntityException; +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReader.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReader.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReader.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,39 +1,39 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 3, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -import java.io.IOException; -import java.util.List; - -/** - * {@link EntityMeta エンティティメタデータ}を読み取るインタフェース。 - * - * @author j5ik2o - */ -public interface EntityMetaReader { - - /** - * エンティティメタデータを読み込む。 - * - * @return {@link EntityMeta}のリスト - * @throws IOException 入出力が失敗した場合 - * @throws EntityClassNotFoundException エンティティクラスがみつからなかった場合 - */ - List<EntityMeta> read() throws IOException, EntityClassNotFoundException; -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 3, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +import java.io.IOException; +import java.util.List; + +/** + * {@link EntityMeta エンティティメタデータ}を読み取るインタフェース。 + * + * @author j5ik2o + */ +public interface EntityMetaReader { + + /** + * エンティティメタデータを読み込む。 + * + * @return {@link EntityMeta}のリスト + * @throws IOException 入出力が失敗した場合 + * @throws EntityClassNotFoundException エンティティクラスがみつからなかった場合 + */ + List<EntityMeta> read() throws IOException, EntityClassNotFoundException; +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReader.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReaderContext.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReaderContext.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReaderContext.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,88 +1,88 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 3, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -import java.io.File; -import java.util.List; -import java.util.regex.Pattern; - -/** - * {@link EntityMetaReader}のコンテキストインターフェイス。 - * - * @author j5ik2o - */ -public interface EntityMetaReaderContext { - - /** - * クラスパスのリストを取得する。 - * - * @return クラスパスのリスト - */ - List<File> getClassPathDirs(); - - /** - * {@link EntityMetaFactory}を取得する。 - * - * @return {@link EntityMetaFactory} - */ - EntityMetaFactory getEntityMetaFactory(); - - /** - * 無視するクラス名のパターンのリストを取得する。 - * - * @return 無視するクラス名パターンのリスト - */ - List<Pattern> getIgnoreShortClassNamePatterns(); - - /** - * Javaファイルのエンコーディングを取得する。 - * - * @return Javaファイルのエンコーディング - */ - String getJavaFileEncoding(); - - /** - * Javaソースファイルのディレクトリのリストを取得する。 - * - * @return Javaソースファイルのディレクトリのリスト - */ - List<File> getJavaSrcFileDirs(); - - /** - * パッケージ名を取得する。 - * - * @return パッケージ名 - */ - String getPackageName(); - - /** - * 短いクラス名のパターンのリストを取得する。 - * - * @return 短いクラス名のパターンのリスト - */ - List<Pattern> getShortClassNamePatterns(); - - /** - * コメントを処理するかどうかのフラグを取得する。 - * - * @return コメント処理フラグ - */ - boolean isReadComment(); - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 3, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +import java.io.File; +import java.util.List; +import java.util.regex.Pattern; + +/** + * {@link EntityMetaReader}のコンテキストインターフェイス。 + * + * @author j5ik2o + */ +public interface EntityMetaReaderContext { + + /** + * クラスパスのリストを取得する。 + * + * @return クラスパスのリスト + */ + List<File> getClassPathDirs(); + + /** + * {@link EntityMetaFactory}を取得する。 + * + * @return {@link EntityMetaFactory} + */ + EntityMetaFactory getEntityMetaFactory(); + + /** + * 無視するクラス名のパターンのリストを取得する。 + * + * @return 無視するクラス名パターンのリスト + */ + List<Pattern> getIgnoreShortClassNamePatterns(); + + /** + * Javaファイルのエンコーディングを取得する。 + * + * @return Javaファイルのエンコーディング + */ + String getJavaFileEncoding(); + + /** + * Javaソースファイルのディレクトリのリストを取得する。 + * + * @return Javaソースファイルのディレクトリのリスト + */ + List<File> getJavaSrcFileDirs(); + + /** + * パッケージ名を取得する。 + * + * @return パッケージ名 + */ + String getPackageName(); + + /** + * 短いクラス名のパターンのリストを取得する。 + * + * @return 短いクラス名のパターンのリスト + */ + List<Pattern> getShortClassNamePatterns(); + + /** + * コメントを処理するかどうかのフラグを取得する。 + * + * @return コメント処理フラグ + */ + boolean isReadComment(); + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReaderContext.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReaderFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReaderFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReaderFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,36 +1,36 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 10, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -/** - * {@link EntityMetaReader}用のファクトリインターフェイス。 - * - * @author j5ik2o - */ -public interface EntityMetaReaderFactory { - - /** - * {@link EntityMetaReader}を生成する。 - * - * @param entityMetaReaderContext {@link EntityMetaReaderContext} - * @return {@link EntityMetaReader} - */ - EntityMetaReader createEntityMetaReader(EntityMetaReaderContext entityMetaReaderContext); - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 10, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +/** + * {@link EntityMetaReader}用のファクトリインターフェイス。 + * + * @author j5ik2o + */ +public interface EntityMetaReaderFactory { + + /** + * {@link EntityMetaReader}を生成する。 + * + * @param entityMetaReaderContext {@link EntityMetaReaderContext} + * @return {@link EntityMetaReader} + */ + EntityMetaReader createEntityMetaReader(EntityMetaReaderContext entityMetaReaderContext); + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaReaderFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/JoinColumnMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/JoinColumnMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/JoinColumnMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,93 +1,93 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 5, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -import org.apache.commons.lang.StringUtils; - -/** - * 関連のカラムを指定するためのメタデータ。 - * - * @author j5ik2o - */ -public class JoinColumnMeta { - - /** 外部キーのカラム名 */ - private String name; - - /** 関連テーブルの主キーのカラム名 */ - private String referencedColumnName; - - - /** - * {@link JoinColumnMeta}を作成する。 - */ - public JoinColumnMeta() { - } - - /** - * {@link JoinColumnMeta}を作成する。 - * - * @param name 外部キーのカラム名 - * @param referencedColumnName 関連テーブルの主キーのカラム名 - */ - public JoinColumnMeta(String name, String referencedColumnName) { - if (StringUtils.isBlank(name) == false) { - this.name = name; - } - if (StringUtils.isBlank(referencedColumnName) == false) { - this.referencedColumnName = referencedColumnName; - } - } - - /** - * 外部キーのカラム名を取得する。 - * - * @return 外部キーのカラム名 - */ - public String getName() { - return name; - } - - /** - * 関連テーブルの主キーのカラム名を取得する。 - * - * @return 関連テーブルの主キーのカラム名 - */ - public String getReferencedColumnName() { - return referencedColumnName; - } - - /** - * 外部キーのカラム名を設定する。 - * - * @param name 外部キーのカラム名 - */ - public void setName(String name) { - this.name = name; - } - - /** - * 関連テーブルの主キーのカラム名を設定する。 - * - * @param referencedColumnName 関連テーブルの主キーのカラム名 - */ - public void setReferencedColumnName(String referencedColumnName) { - this.referencedColumnName = referencedColumnName; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 5, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +import org.apache.commons.lang.StringUtils; + +/** + * 関連のカラムを指定するためのメタデータ。 + * + * @author j5ik2o + */ +public class JoinColumnMeta { + + /** 外部キーのカラム名 */ + private String name; + + /** 関連テーブルの主キーのカラム名 */ + private String referencedColumnName; + + + /** + * {@link JoinColumnMeta}を作成する。 + */ + public JoinColumnMeta() { + } + + /** + * {@link JoinColumnMeta}を作成する。 + * + * @param name 外部キーのカラム名 + * @param referencedColumnName 関連テーブルの主キーのカラム名 + */ + public JoinColumnMeta(String name, String referencedColumnName) { + if (StringUtils.isBlank(name) == false) { + this.name = name; + } + if (StringUtils.isBlank(referencedColumnName) == false) { + this.referencedColumnName = referencedColumnName; + } + } + + /** + * 外部キーのカラム名を取得する。 + * + * @return 外部キーのカラム名 + */ + public String getName() { + return name; + } + + /** + * 関連テーブルの主キーのカラム名を取得する。 + * + * @return 関連テーブルの主キーのカラム名 + */ + public String getReferencedColumnName() { + return referencedColumnName; + } + + /** + * 外部キーのカラム名を設定する。 + * + * @param name 外部キーのカラム名 + */ + public void setName(String name) { + this.name = name; + } + + /** + * 関連テーブルの主キーのカラム名を設定する。 + * + * @param referencedColumnName 関連テーブルの主キーのカラム名 + */ + public void setReferencedColumnName(String referencedColumnName) { + this.referencedColumnName = referencedColumnName; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/JoinColumnMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/NonEntityException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/NonEntityException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/NonEntityException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,64 +1,64 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 4, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -/** - * エンティティではない場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class NonEntityException extends Exception { - - /** - * インスタンスを生成する。 - */ - public NonEntityException() { - super(); - } - - /** - * インスタンスを生成する。 - * - * @param message メッセージ - */ - public NonEntityException(String message) { - super(message); - } - - /** - * インスタンスを生成する。 - * - * @param message メッセージ - * @param cause 原因 - */ - public NonEntityException(String message, Throwable cause) { - super(message, cause); - } - - /** - * インスタンスを生成する。 - * - * @param cause 原因 - */ - public NonEntityException(Throwable cause) { - super(cause); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 4, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +/** + * エンティティではない場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class NonEntityException extends Exception { + + /** + * インスタンスを生成する。 + */ + public NonEntityException() { + super(); + } + + /** + * インスタンスを生成する。 + * + * @param message メッセージ + */ + public NonEntityException(String message) { + super(message); + } + + /** + * インスタンスを生成する。 + * + * @param message メッセージ + * @param cause 原因 + */ + public NonEntityException(String message, Throwable cause) { + super(message, cause); + } + + /** + * インスタンスを生成する。 + * + * @param cause 原因 + */ + public NonEntityException(Throwable cause) { + super(cause); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/NonEntityException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyDuplicatedException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyDuplicatedException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyDuplicatedException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,40 +1,40 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 5, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -/** - * プロパティがだぶって生成された場合の例外クラス - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class PropertyDuplicatedException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param propertyName オリジナルのプロパティ名 - * @param targetPropertyName 対象のプロパティ名 - */ - public PropertyDuplicatedException(String propertyName, String targetPropertyName) { - super(String.format("Duplicated property.(propertyName = %s,targetPropertyName = %s)", propertyName, - targetPropertyName)); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 5, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +/** + * プロパティがだぶって生成された場合の例外クラス + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class PropertyDuplicatedException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param propertyName オリジナルのプロパティ名 + * @param targetPropertyName 対象のプロパティ名 + */ + public PropertyDuplicatedException(String propertyName, String targetPropertyName) { + super(String.format("Duplicated property.(propertyName = %s,targetPropertyName = %s)", propertyName, + targetPropertyName)); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyDuplicatedException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,503 +1,503 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 3, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.persistence.EnumType; -import javax.persistence.FetchType; -import javax.persistence.GenerationType; -import javax.persistence.TemporalType; - -import org.apache.commons.lang.builder.ToStringBuilder; - -import org.jiemamy.entity.io.meta.generator.IdentityIdGeneratorMeta; -import org.jiemamy.entity.io.meta.generator.SequenceIdGeneratorMeta; -import org.jiemamy.entity.io.meta.generator.TableIdGeneratorMeta; -import org.jiemamy.utils.CollectionsUtil; - -/** - * JPA用のプロパティメタデータクラス。 - * - * @author j5ik2o - */ -public class PropertyMeta { - - /** 名前 */ - private String name; - - /** プロパティクラス */ - private Class<?> propertyClass; - - /** フィールド */ - private Field field; - - /** IDフラグ */ - private boolean id; - - /** カラムメタデータ */ - private ColumnMeta columnMeta; - - /** IDを自動生成する方法 */ - private GenerationType generationType; - - /** フェッチタイプ */ - private FetchType fetchType; - - /** 時制の種別 */ - private TemporalType temporalType; - - /** enumの種別 */ - private EnumType enumType; - - /** バージョンフラグ */ - private boolean version; - - /** 一時的フラグ*/ - private boolean trnsient; - - /** <code>LOB</code>フラグ */ - private boolean lob; - - /** 結合カラムメタデータのリスト */ - private List<JoinColumnMeta> joinColumnMetaList = new ArrayList<JoinColumnMeta>(); - - /** 関連タイプ */ - private RelationshipType relationshipType; - - /** 関連の所有者側のプロパティ名 */ - private String mappedBy; - - /** 関連クラス */ - private Class<?> relationshipClass; - - /** {@link SequenceIdGeneratorMeta} */ - private SequenceIdGeneratorMeta sequenceIdGenerator; - - /** {@link IdentityIdGeneratorMeta} */ - private IdentityIdGeneratorMeta identityIdGenerator; - - /** {@link TableIdGeneratorMeta} */ - private TableIdGeneratorMeta tableIdGenerator; - - /** 追加情報 */ - private Map<String, Object> additionalInfo = CollectionsUtil.newHashMap(); - - - /** - * 追加情報を追加する。 - * - * @param <T> 値の型 - * @param key 追加情報のキー - * @param value 値 - */ - public <T>void addAdditionalInfo(String key, T value) { - additionalInfo.put(key, value); - } - - /** - * 結合カラムメタデータを追加する。 - * - * @param joinColumnMeta 結合カラムメタデータ - */ - public void addJoinColumnMeta(JoinColumnMeta joinColumnMeta) { - joinColumnMetaList.add(joinColumnMeta); - } - - /** - * 追加情報を取得する。 - * - * @param <T> 値の型 - * @param key キー - * @return 値 - */ - @SuppressWarnings("unchecked") - public <T>T getAdditionalInfo(String key) { - return (T) additionalInfo.get(key); - } - - /** - * カラムメタを取得する。 - * - * @return {@link ColumnMeta} - */ - public ColumnMeta getColumnMeta() { - return columnMeta; - } - - /** - * {@link EnumType}を取得する。 - * - * @return {@link EnumType} - */ - public EnumType getEnumType() { - return enumType; - } - - /** - * {@link FetchType}を取得する。 - * - * @return {@link FetchType} - */ - public FetchType getFetchType() { - return fetchType; - } - - /** - * フィールドを取得する。 - * - * @return {@link Field} - */ - public Field getField() { - return field; - } - - /** - * {@link GenerationType}を取得する。 - * - * @return {@link GenerationType} - */ - public GenerationType getGenerationType() { - return generationType; - } - - /** - * {@link IdentityIdGeneratorMeta}を取得する。 - * - * @return {@link IdentityIdGeneratorMeta} - */ - public IdentityIdGeneratorMeta getIdentityIdGenerator() { - return identityIdGenerator; - } - - /** - * {@JoinColumnMeta}のリストを取得する。 - * - * @return {@JoinColumnMeta}のリスト - */ - public List<JoinColumnMeta> getJoinColumnMetaList() { - return joinColumnMetaList; - } - - /** - * mappedBy属性を取得する。 - * - * @return mappedBy属性 - */ - public String getMappedBy() { - return mappedBy; - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return name; - } - - /** - * プロパティクラスを取得する。 - * - * @return プロパティクラス - */ - public Class<?> getPropertyClass() { - return propertyClass; - } - - /** - * 関連クラスを取得する。 - * - * @return 関連クラス - */ - public Class<?> getRelationshipClass() { - return relationshipClass; - } - - /** - * {@link RelationshipType}を取得する。 - * - * @return {@link RelationshipType} - */ - public RelationshipType getRelationshipType() { - return relationshipType; - } - - /** - * {@link SequenceIdGeneratorMeta}を取得する。 - * - * @return {@link SequenceIdGeneratorMeta} - */ - public SequenceIdGeneratorMeta getSequenceIdGenerator() { - return sequenceIdGenerator; - } - - /** - * {@link TableIdGeneratorMeta}を取得する。 - * - * @return {@link TableIdGeneratorMeta} - */ - public TableIdGeneratorMeta getTableIdGenerator() { - return tableIdGenerator; - } - - /** - * {@link TemporalType}を取得する。 - * - * @return {@link TemporalType} - */ - public TemporalType getTemporalType() { - return temporalType; - } - - /** - * 識別子を自動生成するIDジェネレータを設定する。 - * - * @return 識別子を自動生成するIDジェネレータ - */ - public boolean hasIdGenerator() { - return generationType != null; - } - - /** - * IDフラグを取得する。 - * - * @return trueの場合はID - */ - public boolean isId() { - return id; - } - - /** - * LOBフラグを取得する。 - * - * @return LOBフラグ - */ - public boolean isLob() { - return lob; - } - - /** - * 関連かどうかを取得する。 - * - * @return 関連かどうか - */ - public boolean isRelationship() { - return relationshipType != null; - } - - /** - * <code>transient</code>フラグを取得する。 - * - * @return <code>transient</code> - */ - public boolean isTransient() { - return trnsient; - } - - /** - * バージョンフラグを取得する。 - * - * @return バージョンフラグ - */ - public boolean isVersion() { - return version; - } - - /** - * カラムメタを設定する。 - * - * @param columnMeta {@link ColumnMeta} - */ - public void setColumnMeta(final ColumnMeta columnMeta) { - this.columnMeta = columnMeta; - } - - /** - * {@link EnumType}を設定する。 - * - * @param enumType {@link EnumType} - */ - public void setEnumType(EnumType enumType) { - this.enumType = enumType; - } - - /** - * {@link FetchType}を設定する。 - * - * @param fetchType {@link FetchType} - */ - public void setFetchType(FetchType fetchType) { - this.fetchType = fetchType; - } - - /** - * フィールドを設定する。 - * - * @param field {@link Field} - */ - public void setField(Field field) { - this.field = field; - } - - /** - * {@link GenerationType}を設定する。 - * - * @param generationType {@link GenerationType} - */ - public void setGenerationType(GenerationType generationType) { - this.generationType = generationType; - } - - /** - * IDフラグを設定する。 - * - * @param id IDフラグ - */ - public void setId(boolean id) { - this.id = id; - } - - /** - * {@link IdentityIdGeneratorMeta}を設定する。 - * - * @param identityIdGenerator {@link IdentityIdGeneratorMeta} - */ - public void setIdentityIdGenerator(IdentityIdGeneratorMeta identityIdGenerator) { - this.identityIdGenerator = identityIdGenerator; - } - - /** - * ジョインカラムメタのリストを設定する。 - * - * @param joinColumnMetaList ジョインカラムメタのリスト - */ - public void setJoinColumnMetaList(List<JoinColumnMeta> joinColumnMetaList) { - this.joinColumnMetaList = joinColumnMetaList; - } - - /** - * LOBフラグを設定する。 - * - * @param lob LOBフラグ - */ - public void setLob(boolean lob) { - this.lob = lob; - } - - /** - * mappedBy属性を設定する。 - * - * @param mappedBy mappedBy属性 - */ - public void setMappedBy(String mappedBy) { - this.mappedBy = mappedBy; - } - - /** - * 名前を設定する。 - * - * @param name 名前 - */ - public void setName(String name) { - this.name = name; - } - - /** - * プロパティクラスを設定する。 - * - * @param propertyClass プロパティクラス - */ - public void setPropertyClass(Class<?> propertyClass) { - this.propertyClass = propertyClass; - } - - /** - * 関連クラスを設定する。 - * - * @param relationshipClass 関連クラス - */ - public void setRelationshipClass(Class<?> relationshipClass) { - this.relationshipClass = relationshipClass; - } - - /** - * {@link RelationshipType}を設定する。 - * - * @param relationshipType {@link RelationshipType} - */ - public void setRelationshipType(RelationshipType relationshipType) { - this.relationshipType = relationshipType; - } - - /** - * {@link SequenceIdGeneratorMeta}を設定する。 - * - * @param sequenceIdGenerator {@link SequenceIdGeneratorMeta} - */ - public void setSequenceIdGenerator(SequenceIdGeneratorMeta sequenceIdGenerator) { - this.sequenceIdGenerator = sequenceIdGenerator; - } - - /** - * {@link TableIdGeneratorMeta}を設定する。 - * - * @param tableIdGenerator {@link TableIdGeneratorMeta} - */ - public void setTableIdGenerator(TableIdGeneratorMeta tableIdGenerator) { - this.tableIdGenerator = tableIdGenerator; - } - - /** - * {@link TemporalType}を設定する。 - * - * @param temporalType {@link TemporalType} - */ - public void setTemporalType(TemporalType temporalType) { - this.temporalType = temporalType; - } - - /** - * <code>transient</code>フラグを設定する。 - * - * @param trnsient <code>transient</code>フラグ - */ - public void setTransient(boolean trnsient) { - this.trnsient = trnsient; - } - - /** - * バージョンフラグを設定する。 - * - * @param version バージョンフラグ - */ - public void setVersion(boolean version) { - this.version = version; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 3, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.persistence.EnumType; +import javax.persistence.FetchType; +import javax.persistence.GenerationType; +import javax.persistence.TemporalType; + +import org.apache.commons.lang.builder.ToStringBuilder; + +import org.jiemamy.entity.io.meta.generator.IdentityIdGeneratorMeta; +import org.jiemamy.entity.io.meta.generator.SequenceIdGeneratorMeta; +import org.jiemamy.entity.io.meta.generator.TableIdGeneratorMeta; +import org.jiemamy.utils.CollectionsUtil; + +/** + * JPA用のプロパティメタデータクラス。 + * + * @author j5ik2o + */ +public class PropertyMeta { + + /** 名前 */ + private String name; + + /** プロパティクラス */ + private Class<?> propertyClass; + + /** フィールド */ + private Field field; + + /** IDフラグ */ + private boolean id; + + /** カラムメタデータ */ + private ColumnMeta columnMeta; + + /** IDを自動生成する方法 */ + private GenerationType generationType; + + /** フェッチタイプ */ + private FetchType fetchType; + + /** 時制の種別 */ + private TemporalType temporalType; + + /** enumの種別 */ + private EnumType enumType; + + /** バージョンフラグ */ + private boolean version; + + /** 一時的フラグ*/ + private boolean trnsient; + + /** <code>LOB</code>フラグ */ + private boolean lob; + + /** 結合カラムメタデータのリスト */ + private List<JoinColumnMeta> joinColumnMetaList = new ArrayList<JoinColumnMeta>(); + + /** 関連タイプ */ + private RelationshipType relationshipType; + + /** 関連の所有者側のプロパティ名 */ + private String mappedBy; + + /** 関連クラス */ + private Class<?> relationshipClass; + + /** {@link SequenceIdGeneratorMeta} */ + private SequenceIdGeneratorMeta sequenceIdGenerator; + + /** {@link IdentityIdGeneratorMeta} */ + private IdentityIdGeneratorMeta identityIdGenerator; + + /** {@link TableIdGeneratorMeta} */ + private TableIdGeneratorMeta tableIdGenerator; + + /** 追加情報 */ + private Map<String, Object> additionalInfo = CollectionsUtil.newHashMap(); + + + /** + * 追加情報を追加する。 + * + * @param <T> 値の型 + * @param key 追加情報のキー + * @param value 値 + */ + public <T>void addAdditionalInfo(String key, T value) { + additionalInfo.put(key, value); + } + + /** + * 結合カラムメタデータを追加する。 + * + * @param joinColumnMeta 結合カラムメタデータ + */ + public void addJoinColumnMeta(JoinColumnMeta joinColumnMeta) { + joinColumnMetaList.add(joinColumnMeta); + } + + /** + * 追加情報を取得する。 + * + * @param <T> 値の型 + * @param key キー + * @return 値 + */ + @SuppressWarnings("unchecked") + public <T>T getAdditionalInfo(String key) { + return (T) additionalInfo.get(key); + } + + /** + * カラムメタを取得する。 + * + * @return {@link ColumnMeta} + */ + public ColumnMeta getColumnMeta() { + return columnMeta; + } + + /** + * {@link EnumType}を取得する。 + * + * @return {@link EnumType} + */ + public EnumType getEnumType() { + return enumType; + } + + /** + * {@link FetchType}を取得する。 + * + * @return {@link FetchType} + */ + public FetchType getFetchType() { + return fetchType; + } + + /** + * フィールドを取得する。 + * + * @return {@link Field} + */ + public Field getField() { + return field; + } + + /** + * {@link GenerationType}を取得する。 + * + * @return {@link GenerationType} + */ + public GenerationType getGenerationType() { + return generationType; + } + + /** + * {@link IdentityIdGeneratorMeta}を取得する。 + * + * @return {@link IdentityIdGeneratorMeta} + */ + public IdentityIdGeneratorMeta getIdentityIdGenerator() { + return identityIdGenerator; + } + + /** + * {@JoinColumnMeta}のリストを取得する。 + * + * @return {@JoinColumnMeta}のリスト + */ + public List<JoinColumnMeta> getJoinColumnMetaList() { + return joinColumnMetaList; + } + + /** + * mappedBy属性を取得する。 + * + * @return mappedBy属性 + */ + public String getMappedBy() { + return mappedBy; + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return name; + } + + /** + * プロパティクラスを取得する。 + * + * @return プロパティクラス + */ + public Class<?> getPropertyClass() { + return propertyClass; + } + + /** + * 関連クラスを取得する。 + * + * @return 関連クラス + */ + public Class<?> getRelationshipClass() { + return relationshipClass; + } + + /** + * {@link RelationshipType}を取得する。 + * + * @return {@link RelationshipType} + */ + public RelationshipType getRelationshipType() { + return relationshipType; + } + + /** + * {@link SequenceIdGeneratorMeta}を取得する。 + * + * @return {@link SequenceIdGeneratorMeta} + */ + public SequenceIdGeneratorMeta getSequenceIdGenerator() { + return sequenceIdGenerator; + } + + /** + * {@link TableIdGeneratorMeta}を取得する。 + * + * @return {@link TableIdGeneratorMeta} + */ + public TableIdGeneratorMeta getTableIdGenerator() { + return tableIdGenerator; + } + + /** + * {@link TemporalType}を取得する。 + * + * @return {@link TemporalType} + */ + public TemporalType getTemporalType() { + return temporalType; + } + + /** + * 識別子を自動生成するIDジェネレータを設定する。 + * + * @return 識別子を自動生成するIDジェネレータ + */ + public boolean hasIdGenerator() { + return generationType != null; + } + + /** + * IDフラグを取得する。 + * + * @return trueの場合はID + */ + public boolean isId() { + return id; + } + + /** + * LOBフラグを取得する。 + * + * @return LOBフラグ + */ + public boolean isLob() { + return lob; + } + + /** + * 関連かどうかを取得する。 + * + * @return 関連かどうか + */ + public boolean isRelationship() { + return relationshipType != null; + } + + /** + * <code>transient</code>フラグを取得する。 + * + * @return <code>transient</code> + */ + public boolean isTransient() { + return trnsient; + } + + /** + * バージョンフラグを取得する。 + * + * @return バージョンフラグ + */ + public boolean isVersion() { + return version; + } + + /** + * カラムメタを設定する。 + * + * @param columnMeta {@link ColumnMeta} + */ + public void setColumnMeta(final ColumnMeta columnMeta) { + this.columnMeta = columnMeta; + } + + /** + * {@link EnumType}を設定する。 + * + * @param enumType {@link EnumType} + */ + public void setEnumType(EnumType enumType) { + this.enumType = enumType; + } + + /** + * {@link FetchType}を設定する。 + * + * @param fetchType {@link FetchType} + */ + public void setFetchType(FetchType fetchType) { + this.fetchType = fetchType; + } + + /** + * フィールドを設定する。 + * + * @param field {@link Field} + */ + public void setField(Field field) { + this.field = field; + } + + /** + * {@link GenerationType}を設定する。 + * + * @param generationType {@link GenerationType} + */ + public void setGenerationType(GenerationType generationType) { + this.generationType = generationType; + } + + /** + * IDフラグを設定する。 + * + * @param id IDフラグ + */ + public void setId(boolean id) { + this.id = id; + } + + /** + * {@link IdentityIdGeneratorMeta}を設定する。 + * + * @param identityIdGenerator {@link IdentityIdGeneratorMeta} + */ + public void setIdentityIdGenerator(IdentityIdGeneratorMeta identityIdGenerator) { + this.identityIdGenerator = identityIdGenerator; + } + + /** + * ジョインカラムメタのリストを設定する。 + * + * @param joinColumnMetaList ジョインカラムメタのリスト + */ + public void setJoinColumnMetaList(List<JoinColumnMeta> joinColumnMetaList) { + this.joinColumnMetaList = joinColumnMetaList; + } + + /** + * LOBフラグを設定する。 + * + * @param lob LOBフラグ + */ + public void setLob(boolean lob) { + this.lob = lob; + } + + /** + * mappedBy属性を設定する。 + * + * @param mappedBy mappedBy属性 + */ + public void setMappedBy(String mappedBy) { + this.mappedBy = mappedBy; + } + + /** + * 名前を設定する。 + * + * @param name 名前 + */ + public void setName(String name) { + this.name = name; + } + + /** + * プロパティクラスを設定する。 + * + * @param propertyClass プロパティクラス + */ + public void setPropertyClass(Class<?> propertyClass) { + this.propertyClass = propertyClass; + } + + /** + * 関連クラスを設定する。 + * + * @param relationshipClass 関連クラス + */ + public void setRelationshipClass(Class<?> relationshipClass) { + this.relationshipClass = relationshipClass; + } + + /** + * {@link RelationshipType}を設定する。 + * + * @param relationshipType {@link RelationshipType} + */ + public void setRelationshipType(RelationshipType relationshipType) { + this.relationshipType = relationshipType; + } + + /** + * {@link SequenceIdGeneratorMeta}を設定する。 + * + * @param sequenceIdGenerator {@link SequenceIdGeneratorMeta} + */ + public void setSequenceIdGenerator(SequenceIdGeneratorMeta sequenceIdGenerator) { + this.sequenceIdGenerator = sequenceIdGenerator; + } + + /** + * {@link TableIdGeneratorMeta}を設定する。 + * + * @param tableIdGenerator {@link TableIdGeneratorMeta} + */ + public void setTableIdGenerator(TableIdGeneratorMeta tableIdGenerator) { + this.tableIdGenerator = tableIdGenerator; + } + + /** + * {@link TemporalType}を設定する。 + * + * @param temporalType {@link TemporalType} + */ + public void setTemporalType(TemporalType temporalType) { + this.temporalType = temporalType; + } + + /** + * <code>transient</code>フラグを設定する。 + * + * @param trnsient <code>transient</code>フラグ + */ + public void setTransient(boolean trnsient) { + this.trnsient = trnsient; + } + + /** + * バージョンフラグを設定する。 + * + * @param version バージョンフラグ + */ + public void setVersion(boolean version) { + this.version = version; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyMetaFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyMetaFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyMetaFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,40 +1,40 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 5, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -import java.lang.reflect.Field; - -/** - * {@link PropertyMeta}のファクトリインターフェイス。 - * - * @author j5ik2o - */ -public interface PropertyMetaFactory { - - /** - * {@link PropertyMeta}を生成する。 - * - * @param entityMeta {@link EntityMeta} - * @param field 対象となるフィールド - * @return {@link PropertyMeta} - * @throws CannotCreatePropertyException プロパティを生成できなかった場合 - */ - PropertyMeta createPropertyMeta(EntityMeta entityMeta, Field field) throws CannotCreatePropertyException; - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 5, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +import java.lang.reflect.Field; + +/** + * {@link PropertyMeta}のファクトリインターフェイス。 + * + * @author j5ik2o + */ +public interface PropertyMetaFactory { + + /** + * {@link PropertyMeta}を生成する。 + * + * @param entityMeta {@link EntityMeta} + * @param field 対象となるフィールド + * @return {@link PropertyMeta} + * @throws CannotCreatePropertyException プロパティを生成できなかった場合 + */ + PropertyMeta createPropertyMeta(EntityMeta entityMeta, Field field) throws CannotCreatePropertyException; + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/PropertyMetaFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/RelationshipType.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/RelationshipType.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/RelationshipType.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,33 +1,33 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 5, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -/** - * リレーションの種別を表す列挙型。 - * - * @author j5ik2o - */ -public enum RelationshipType { - /** 多対一 */ - MANY_TO_ONE, - /** 一対多 */ - ONE_TO_MANY, - /** 一対一 */ - ONE_TO_ONE -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 5, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +/** + * リレーションの種別を表す列挙型。 + * + * @author j5ik2o + */ +public enum RelationshipType { + /** 多対一 */ + MANY_TO_ONE, + /** 一対多 */ + ONE_TO_MANY, + /** 一対一 */ + ONE_TO_ONE +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/RelationshipType.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/TableMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/TableMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/TableMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,136 +1,136 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 3, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -import org.apache.commons.lang.builder.ToStringBuilder; - -/** - * JPA用のテーブルメタデータクラス。 - * - * @author j5ik2o - * - */ -public class TableMeta { - - /** 名前 */ - protected String name; - - /** 論理名 */ - protected String logicalName; - - /** カタログ */ - protected String catalog; - - /** スキーマ */ - protected String schema; - - - /** - * カタログを取得する。 - * - * @return カタログ - */ - public String getCatalog() { - return catalog; - } - - /** - * カタログやスキーマを含んだ完全な名前を取得する。 - * - * @return カタログやスキーマを含んだ完全な名前 - */ - public String getFullName() { - StringBuilder buf = new StringBuilder(); - if (catalog != null) { - buf.append(catalog).append("."); - } - if (schema != null) { - buf.append(schema).append("."); - } - return buf.append(name).toString(); - } - - /** - * 論理名を取得する。 - * - * @return 論理名 - */ - public String getLogicalName() { - return logicalName; - } - - /** - * 名前を取得する。 - * - * @return 名前 - */ - public String getName() { - return name; - } - - /** - * スキーマを取得する。 - * - * @return スキーマ - */ - public String getSchema() { - return schema; - } - - /** - * カタログを設定する。 - * - * @param catalog カタログ - */ - public void setCatalog(String catalog) { - this.catalog = catalog; - } - - /** - * 論理名を設定する。 - * - * @param logicalName 論理名 - */ - public void setLogicalName(String logicalName) { - this.logicalName = logicalName; - } - - /** - * 名前を設定する。 - * - * @param name 名前 - */ - public void setName(String name) { - this.name = name; - } - - /** - * スキーマを設定する。 - * - * @param schema スキーマ - */ - public void setSchema(String schema) { - this.schema = schema; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 3, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * JPA用のテーブルメタデータクラス。 + * + * @author j5ik2o + * + */ +public class TableMeta { + + /** 名前 */ + protected String name; + + /** 論理名 */ + protected String logicalName; + + /** カタログ */ + protected String catalog; + + /** スキーマ */ + protected String schema; + + + /** + * カタログを取得する。 + * + * @return カタログ + */ + public String getCatalog() { + return catalog; + } + + /** + * カタログやスキーマを含んだ完全な名前を取得する。 + * + * @return カタログやスキーマを含んだ完全な名前 + */ + public String getFullName() { + StringBuilder buf = new StringBuilder(); + if (catalog != null) { + buf.append(catalog).append("."); + } + if (schema != null) { + buf.append(schema).append("."); + } + return buf.append(name).toString(); + } + + /** + * 論理名を取得する。 + * + * @return 論理名 + */ + public String getLogicalName() { + return logicalName; + } + + /** + * 名前を取得する。 + * + * @return 名前 + */ + public String getName() { + return name; + } + + /** + * スキーマを取得する。 + * + * @return スキーマ + */ + public String getSchema() { + return schema; + } + + /** + * カタログを設定する。 + * + * @param catalog カタログ + */ + public void setCatalog(String catalog) { + this.catalog = catalog; + } + + /** + * 論理名を設定する。 + * + * @param logicalName 論理名 + */ + public void setLogicalName(String logicalName) { + this.logicalName = logicalName; + } + + /** + * 名前を設定する。 + * + * @param name 名前 + */ + public void setName(String name) { + this.name = name; + } + + /** + * スキーマを設定する。 + * + * @param schema スキーマ + */ + public void setSchema(String schema) { + this.schema = schema; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/TableMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/TableMetaFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/TableMetaFactory.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/TableMetaFactory.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,35 +1,35 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 5, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta; - -/** - * {@link TableMeta}のファクトリクラス。 - * - * @author j5ik2o - */ -public interface TableMetaFactory { - - /** - * テーブルメタデータを作成する。 - * - * @param entityMeta エンティティメタデータ - * @return テーブルメタデータ - */ - TableMeta createTableMeta(EntityMeta entityMeta); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 5, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta; + +/** + * {@link TableMeta}のファクトリクラス。 + * + * @author j5ik2o + */ +public interface TableMetaFactory { + + /** + * テーブルメタデータを作成する。 + * + * @param entityMeta エンティティメタデータ + * @return テーブルメタデータ + */ + TableMeta createTableMeta(EntityMeta entityMeta); +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/TableMetaFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/BothMappedByAndJoinColumnException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/BothMappedByAndJoinColumnException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/BothMappedByAndJoinColumnException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,40 +1,40 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -/** - * mappedByとJoinColumnが両方指定されていた場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class BothMappedByAndJoinColumnException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - */ - public BothMappedByAndJoinColumnException(String entityName, String propertyName) { - super(String.format("Both MappedBy and JoinColumn.(entityName = %s, propertyName = %s)", entityName, - propertyName)); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +/** + * mappedByとJoinColumnが両方指定されていた場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class BothMappedByAndJoinColumnException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + */ + public BothMappedByAndJoinColumnException(String entityName, String propertyName) { + super(String.format("Both MappedBy and JoinColumn.(entityName = %s, propertyName = %s)", entityName, + propertyName)); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/BothMappedByAndJoinColumnException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/FieldDuplicatedException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/FieldDuplicatedException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/FieldDuplicatedException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,40 +1,40 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -import java.lang.reflect.Field; - -/** - * フィールドが重複した場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class FieldDuplicatedException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param field 対象のフィールド - */ - public FieldDuplicatedException(Field field) { - super(String.format("Duplicated field (fieldName = %s)", field.getName())); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +import java.lang.reflect.Field; + +/** + * フィールドが重複した場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class FieldDuplicatedException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param field 対象のフィールド + */ + public FieldDuplicatedException(Field field) { + super(String.format("Duplicated field (fieldName = %s)", field.getName())); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/FieldDuplicatedException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/IdGeneratorNotFoundException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/IdGeneratorNotFoundException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/IdGeneratorNotFoundException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,42 +1,42 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -import org.jiemamy.entity.io.meta.generator.IdGeneratorMeta; - -/** - * {@link IdGeneratorMeta}が見つからなかった場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class IdGeneratorNotFoundException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - * @param generatorName ジェネレータ名 - */ - public IdGeneratorNotFoundException(String entityName, String propertyName, String generatorName) { - super(String.format("IdGenerator is not found.(entityName = %s, propertyName = %s, generatorName = %s)", - entityName, propertyName, generatorName)); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +import org.jiemamy.entity.io.meta.generator.IdGeneratorMeta; + +/** + * {@link IdGeneratorMeta}が見つからなかった場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class IdGeneratorNotFoundException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + * @param generatorName ジェネレータ名 + */ + public IdGeneratorNotFoundException(String entityName, String propertyName, String generatorName) { + super(String.format("IdGenerator is not found.(entityName = %s, propertyName = %s, generatorName = %s)", + entityName, propertyName, generatorName)); + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/IdGeneratorNotFoundException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/JoinColumnNameAndReferencedColumnNameMandatoryException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/JoinColumnNameAndReferencedColumnNameMandatoryException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/JoinColumnNameAndReferencedColumnNameMandatoryException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,41 +1,41 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -/** - * JoinColumnNameとReferencedColumnNameが指定されていない場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class JoinColumnNameAndReferencedColumnNameMandatoryException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - * @param index アノテーションのインデックス - */ - public JoinColumnNameAndReferencedColumnNameMandatoryException(String entityName, String propertyName, int index) { - super(String.format("JoinColumnName and ReferencedColumnName is mandatory." - + "(entityName = %s, propertyName = %s, index = %d)", entityName, propertyName, index)); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +/** + * JoinColumnNameとReferencedColumnNameが指定されていない場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class JoinColumnNameAndReferencedColumnNameMandatoryException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + * @param index アノテーションのインデックス + */ + public JoinColumnNameAndReferencedColumnNameMandatoryException(String entityName, String propertyName, int index) { + super(String.format("JoinColumnName and ReferencedColumnName is mandatory." + + "(entityName = %s, propertyName = %s, index = %d)", entityName, propertyName, index)); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/JoinColumnNameAndReferencedColumnNameMandatoryException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/LazyFetchSpecifiedException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/LazyFetchSpecifiedException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/LazyFetchSpecifiedException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,42 +1,42 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -import javax.persistence.FetchType; - -/** - * フェッチタイプに{@link FetchType#LAZY}が指定された場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class LazyFetchSpecifiedException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - */ - public LazyFetchSpecifiedException(String entityName, String propertyName) { - super(String.format("Not allow lazy fetch specified.(entityName = %s, propertyName = %s)", entityName, - propertyName)); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +import javax.persistence.FetchType; + +/** + * フェッチタイプに{@link FetchType#LAZY}が指定された場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class LazyFetchSpecifiedException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + */ + public LazyFetchSpecifiedException(String entityName, String propertyName) { + super(String.format("Not allow lazy fetch specified.(entityName = %s, propertyName = %s)", entityName, + propertyName)); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/LazyFetchSpecifiedException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/MappedByMandatoryException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/MappedByMandatoryException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/MappedByMandatoryException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,39 +1,39 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -/** - * 一対多関連でmappedByが指定されていない場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class MappedByMandatoryException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - */ - public MappedByMandatoryException(String entityName, String propertyName) { - super(String.format("MappedBy is mandatory.(entityName = %s, propertyName = %s)", entityName, propertyName)); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +/** + * 一対多関連でmappedByが指定されていない場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class MappedByMandatoryException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + */ + public MappedByMandatoryException(String entityName, String propertyName) { + super(String.format("MappedBy is mandatory.(entityName = %s, propertyName = %s)", entityName, propertyName)); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/MappedByMandatoryException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/OneToManyNotGenericsException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/OneToManyNotGenericsException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/OneToManyNotGenericsException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,40 +1,40 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -/** - * 一対多の関連がジェネリクスのリストではない場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class OneToManyNotGenericsException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - */ - public OneToManyNotGenericsException(String entityName, String propertyName) { - super(String.format("oneToMany is not gerenerics.(entityName = %s, propertyName = %s)", entityName, - propertyName)); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +/** + * 一対多の関連がジェネリクスのリストではない場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class OneToManyNotGenericsException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + */ + public OneToManyNotGenericsException(String entityName, String propertyName) { + super(String.format("oneToMany is not gerenerics.(entityName = %s, propertyName = %s)", entityName, + propertyName)); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/OneToManyNotGenericsException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/OneToManyNotListException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/OneToManyNotListException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/OneToManyNotListException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,39 +1,39 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -/** - * 一対多の関連がリストではない場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class OneToManyNotListException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - */ - public OneToManyNotListException(String entityName, String propertyName) { - super(String.format("oneToMay is not List.(entityName = %s, propertyName = %s)", entityName, propertyName)); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +/** + * 一対多の関連がリストではない場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class OneToManyNotListException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + */ + public OneToManyNotListException(String entityName, String propertyName) { + super(String.format("oneToMay is not List.(entityName = %s, propertyName = %s)", entityName, propertyName)); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/OneToManyNotListException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/RelationshipNotEntityException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/RelationshipNotEntityException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/RelationshipNotEntityException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,41 +1,41 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -/** - * 関連がエンティティではない場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class RelationshipNotEntityException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - * @param relationshipClass 関連クラス - */ - public RelationshipNotEntityException(String entityName, String propertyName, Class<?> relationshipClass) { - super(String.format("Relation ship is not entity.(entityName = %s, propertyName = %s)", entityName, - propertyName, relationshipClass)); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +/** + * 関連がエンティティではない場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class RelationshipNotEntityException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + * @param relationshipClass 関連クラス + */ + public RelationshipNotEntityException(String entityName, String propertyName, Class<?> relationshipClass) { + super(String.format("Relation ship is not entity.(entityName = %s, propertyName = %s)", entityName, + propertyName, relationshipClass)); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/RelationshipNotEntityException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/TemporalTypeNotSpecifiedException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/TemporalTypeNotSpecifiedException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/TemporalTypeNotSpecifiedException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,46 +1,46 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -import java.sql.Date; -import java.util.Calendar; - -import javax.persistence.TemporalType; - -/** - * {@link Date} や {@link Calendar} 型のプロパティに {@link TemporalType} - * が設定されていない場合にスローされる例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class TemporalTypeNotSpecifiedException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - */ - public TemporalTypeNotSpecifiedException(String entityName, String propertyName) { - super(String.format("TemporalType is not specified.(entityName = %s, propertyName = %s)", entityName, - propertyName)); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +import java.sql.Date; +import java.util.Calendar; + +import javax.persistence.TemporalType; + +/** + * {@link Date} や {@link Calendar} 型のプロパティに {@link TemporalType} + * が設定されていない場合にスローされる例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class TemporalTypeNotSpecifiedException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + */ + public TemporalTypeNotSpecifiedException(String entityName, String propertyName) { + super(String.format("TemporalType is not specified.(entityName = %s, propertyName = %s)", entityName, + propertyName)); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/TemporalTypeNotSpecifiedException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedInheritanceException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedInheritanceException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedInheritanceException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,38 +1,38 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -/** - * サポートしていない継承の場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class UnsupportedInheritanceException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityClass エンティティクラス - */ - public UnsupportedInheritanceException(Class<?> entityClass) { - super(String.format("Unsupported inheritance.(entityClassName = %s)", entityClass.getName())); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +/** + * サポートしていない継承の場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class UnsupportedInheritanceException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityClass エンティティクラス + */ + public UnsupportedInheritanceException(Class<?> entityClass) { + super(String.format("Unsupported inheritance.(entityClassName = %s)", entityClass.getName())); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedInheritanceException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedPropertyTypesException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedPropertyTypesException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedPropertyTypesException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,41 +1,41 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -/** - * サポートしていないプロパティの型の例外クラス。 - * - * @author j5i2ko - */ - @ SuppressWarnings("serial") -public class UnsupportedPropertyTypesException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - * @param propertyClass プロパティクラス - */ - public UnsupportedPropertyTypesException(String entityName, String propertyName, Class<?> propertyClass) { - super(String.format("Unsupported property types.(entityName = %s, propertyName = %s, propertyClassName = %s)", - entityName, propertyName, propertyClass.getName())); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +/** + * サポートしていないプロパティの型の例外クラス。 + * + * @author j5i2ko + */ + @ SuppressWarnings("serial") +public class UnsupportedPropertyTypesException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + * @param propertyClass プロパティクラス + */ + public UnsupportedPropertyTypesException(String entityName, String propertyName, Class<?> propertyClass) { + super(String.format("Unsupported property types.(entityName = %s, propertyName = %s, propertyClassName = %s)", + entityName, propertyName, propertyClass.getName())); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedPropertyTypesException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedRelationshipException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedRelationshipException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedRelationshipException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,39 +1,39 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -/** - * サポートしていない関連の場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class UnsupportedRelationshipException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - */ - public UnsupportedRelationshipException(String entityName, String propertyName) { - super(String.format("Unsupported relation ship.(entityName = %s, propertyName = %s)", entityName, propertyName)); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +/** + * サポートしていない関連の場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class UnsupportedRelationshipException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + */ + public UnsupportedRelationshipException(String entityName, String propertyName) { + super(String.format("Unsupported relation ship.(entityName = %s, propertyName = %s)", entityName, propertyName)); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/UnsupportedRelationshipException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/VersionPropertyNotNumberException.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/VersionPropertyNotNumberException.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/VersionPropertyNotNumberException.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,40 +1,40 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.exception; - -/** - * バージョンプロパティが数値型でない場合の例外クラス。 - * - * @author j5ik2o - */ - @ SuppressWarnings("serial") -public class VersionPropertyNotNumberException extends Exception { - - /** - * インスタンスを生成する。 - * - * @param entityName エンティティ名 - * @param propertyName プロパティ名 - */ - public VersionPropertyNotNumberException(String entityName, String propertyName) { - super(String.format("Version property is not number.(entityName = %s, propertyName = %s)", entityName, - propertyName)); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.exception; + +/** + * バージョンプロパティが数値型でない場合の例外クラス。 + * + * @author j5ik2o + */ + @ SuppressWarnings("serial") +public class VersionPropertyNotNumberException extends Exception { + + /** + * インスタンスを生成する。 + * + * @param entityName エンティティ名 + * @param propertyName プロパティ名 + */ + public VersionPropertyNotNumberException(String entityName, String propertyName) { + super(String.format("Version property is not number.(entityName = %s, propertyName = %s)", entityName, + propertyName)); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/exception/VersionPropertyNotNumberException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/AbstractIdGeneratorMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/AbstractIdGeneratorMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/AbstractIdGeneratorMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,68 +1,68 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.generator; - -import org.jiemamy.entity.io.meta.EntityMeta; -import org.jiemamy.entity.io.meta.PropertyMeta; - -/** - * 識別子を自動生成するIDジェネレータメタの抽象クラス。 - * - * @author j5ik2o - */ -public abstract class AbstractIdGeneratorMeta implements IdGeneratorMeta { - - /** エンティティメタデータ */ - private EntityMeta entityMeta; - - /** プロパティメタデータ */ - private PropertyMeta propertyMeta; - - - /** - * インスタンスを構築する。 - * - * @param entityMeta エンティティメタデータ - * @param propertyMeta プロパティメタデータ - */ - public AbstractIdGeneratorMeta(final EntityMeta entityMeta, final PropertyMeta propertyMeta) { - super(); - this.entityMeta = entityMeta; - this.propertyMeta = propertyMeta; - } - - /** - * {@link EntityMeta}を取得する。 - * - * @return {@link EntityMeta} - */ - public EntityMeta getEntityMeta() { - return entityMeta; - } - - /** - * {@link PropertyMeta}を取得する。 - * - * @return {@link PropertyMeta} - */ - public PropertyMeta getPropertyMeta() { - return propertyMeta; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.generator; + +import org.jiemamy.entity.io.meta.EntityMeta; +import org.jiemamy.entity.io.meta.PropertyMeta; + +/** + * 識別子を自動生成するIDジェネレータメタの抽象クラス。 + * + * @author j5ik2o + */ +public abstract class AbstractIdGeneratorMeta implements IdGeneratorMeta { + + /** エンティティメタデータ */ + private EntityMeta entityMeta; + + /** プロパティメタデータ */ + private PropertyMeta propertyMeta; + + + /** + * インスタンスを構築する。 + * + * @param entityMeta エンティティメタデータ + * @param propertyMeta プロパティメタデータ + */ + public AbstractIdGeneratorMeta(final EntityMeta entityMeta, final PropertyMeta propertyMeta) { + super(); + this.entityMeta = entityMeta; + this.propertyMeta = propertyMeta; + } + + /** + * {@link EntityMeta}を取得する。 + * + * @return {@link EntityMeta} + */ + public EntityMeta getEntityMeta() { + return entityMeta; + } + + /** + * {@link PropertyMeta}を取得する。 + * + * @return {@link PropertyMeta} + */ + public PropertyMeta getPropertyMeta() { + return propertyMeta; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/AbstractIdGeneratorMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/AbstractPreAllocateIdGeneratorMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/AbstractPreAllocateIdGeneratorMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/AbstractPreAllocateIdGeneratorMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,85 +1,85 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.generator; - -import org.jiemamy.entity.io.meta.EntityMeta; -import org.jiemamy.entity.io.meta.PropertyMeta; - -/** - * INSERT前に識別子を自動生成するIDジェネレータメタの抽象クラスです。 - * - * @author j5ik2o - */ -public abstract class AbstractPreAllocateIdGeneratorMeta extends AbstractIdGeneratorMeta { - - /** 割り当てサイズ */ - private long allocationSize; - - /** 名前 */ - private String name; - - /** 初期値 */ - private long initialValue; - - - /** - * インスタンスを構築する。 - * - * @param entityMeta エンティティメタデータ - * @param propertyMeta プロパティメタデータ - * @param name ジェネレータ名 - * @param initialValue 初期値 - * @param allocationSize 割り当てサイズ - */ - public AbstractPreAllocateIdGeneratorMeta(final EntityMeta entityMeta, final PropertyMeta propertyMeta, - String name, long initialValue, long allocationSize) { - super(entityMeta, propertyMeta); - this.name = name; - this.initialValue = initialValue; - this.allocationSize = allocationSize; - } - - /** - * 割り当てサイズを取得する。 - * - * @return 割り当てサイズ - */ - public long getAllocationSize() { - return allocationSize; - } - - /** - * シーケンスの初期値を取得する。 - * - * @return シーケンスの初期値 - */ - public long getInitialValue() { - return initialValue; - } - - /** - * ジェネレータ名を取得する。 - * - * @return ジェネレータ名 - */ - public String getName() { - return name; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.generator; + +import org.jiemamy.entity.io.meta.EntityMeta; +import org.jiemamy.entity.io.meta.PropertyMeta; + +/** + * INSERT前に識別子を自動生成するIDジェネレータメタの抽象クラスです。 + * + * @author j5ik2o + */ +public abstract class AbstractPreAllocateIdGeneratorMeta extends AbstractIdGeneratorMeta { + + /** 割り当てサイズ */ + private long allocationSize; + + /** 名前 */ + private String name; + + /** 初期値 */ + private long initialValue; + + + /** + * インスタンスを構築する。 + * + * @param entityMeta エンティティメタデータ + * @param propertyMeta プロパティメタデータ + * @param name ジェネレータ名 + * @param initialValue 初期値 + * @param allocationSize 割り当てサイズ + */ + public AbstractPreAllocateIdGeneratorMeta(final EntityMeta entityMeta, final PropertyMeta propertyMeta, + String name, long initialValue, long allocationSize) { + super(entityMeta, propertyMeta); + this.name = name; + this.initialValue = initialValue; + this.allocationSize = allocationSize; + } + + /** + * 割り当てサイズを取得する。 + * + * @return 割り当てサイズ + */ + public long getAllocationSize() { + return allocationSize; + } + + /** + * シーケンスの初期値を取得する。 + * + * @return シーケンスの初期値 + */ + public long getInitialValue() { + return initialValue; + } + + /** + * ジェネレータ名を取得する。 + * + * @return ジェネレータ名 + */ + public String getName() { + return name; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/AbstractPreAllocateIdGeneratorMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/IdGeneratorMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/IdGeneratorMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/IdGeneratorMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,28 +1,28 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.generator; - -/** - * 識別子を自動生成するIDジェネレータメタのインターフェースです。 - * - * @author j5ik2o - */ -public interface IdGeneratorMeta { - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.generator; + +/** + * 識別子を自動生成するIDジェネレータメタのインターフェースです。 + * + * @author j5ik2o + */ +public interface IdGeneratorMeta { + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/IdGeneratorMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/IdentityIdGeneratorMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/IdentityIdGeneratorMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/IdentityIdGeneratorMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,43 +1,43 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.generator; - -import javax.persistence.GenerationType; - -import org.jiemamy.entity.io.meta.EntityMeta; -import org.jiemamy.entity.io.meta.PropertyMeta; - -/** - * {@link GenerationType#IDENTITY}方式で識別子の値を自動生成するIDジェネレータメタ。 - * - * @author j5ik2o - */ -public class IdentityIdGeneratorMeta extends AbstractIdGeneratorMeta { - - /** - * インスタンスを生成する。 - * - * @param entityMeta {@link EntityMeta} - * @param propertyMeta {@link PropertyMeta} - */ - public IdentityIdGeneratorMeta(EntityMeta entityMeta, PropertyMeta propertyMeta) { - super(entityMeta, propertyMeta); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.generator; + +import javax.persistence.GenerationType; + +import org.jiemamy.entity.io.meta.EntityMeta; +import org.jiemamy.entity.io.meta.PropertyMeta; + +/** + * {@link GenerationType#IDENTITY}方式で識別子の値を自動生成するIDジェネレータメタ。 + * + * @author j5ik2o + */ +public class IdentityIdGeneratorMeta extends AbstractIdGeneratorMeta { + + /** + * インスタンスを生成する。 + * + * @param entityMeta {@link EntityMeta} + * @param propertyMeta {@link PropertyMeta} + */ + public IdentityIdGeneratorMeta(EntityMeta entityMeta, PropertyMeta propertyMeta) { + super(entityMeta, propertyMeta); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/IdentityIdGeneratorMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/SequenceIdGeneratorMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/SequenceIdGeneratorMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/SequenceIdGeneratorMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,56 +1,56 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.generator; - -import javax.persistence.SequenceGenerator; - -import org.jiemamy.entity.io.meta.EntityMeta; -import org.jiemamy.entity.io.meta.PropertyMeta; - -/** - * {@link SequenceGenerator}のメタデータを保持するクラス。 - * - * @author j5ik2o - */ -public class SequenceIdGeneratorMeta extends AbstractPreAllocateIdGeneratorMeta { - - private String sequenceName; - - - /** - * インスタンスを生成する。 - * - * @param entityMeta {@link EntityMeta} - * @param propertyMeta {@link PropertyMeta} - * @param sequenceGenerator {@link SequenceGenerator} - */ - public SequenceIdGeneratorMeta(EntityMeta entityMeta, PropertyMeta propertyMeta, SequenceGenerator sequenceGenerator) { - super(entityMeta, propertyMeta, sequenceGenerator.name(), sequenceGenerator.initialValue(), sequenceGenerator - .allocationSize()); - } - - /** - * シーケンス名を取得する。 - * - * @return シーケンス名 - */ - public String getSequenceName() { - return sequenceName; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.generator; + +import javax.persistence.SequenceGenerator; + +import org.jiemamy.entity.io.meta.EntityMeta; +import org.jiemamy.entity.io.meta.PropertyMeta; + +/** + * {@link SequenceGenerator}のメタデータを保持するクラス。 + * + * @author j5ik2o + */ +public class SequenceIdGeneratorMeta extends AbstractPreAllocateIdGeneratorMeta { + + private String sequenceName; + + + /** + * インスタンスを生成する。 + * + * @param entityMeta {@link EntityMeta} + * @param propertyMeta {@link PropertyMeta} + * @param sequenceGenerator {@link SequenceGenerator} + */ + public SequenceIdGeneratorMeta(EntityMeta entityMeta, PropertyMeta propertyMeta, SequenceGenerator sequenceGenerator) { + super(entityMeta, propertyMeta, sequenceGenerator.name(), sequenceGenerator.initialValue(), sequenceGenerator + .allocationSize()); + } + + /** + * シーケンス名を取得する。 + * + * @return シーケンス名 + */ + public String getSequenceName() { + return sequenceName; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/SequenceIdGeneratorMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/TableIdGeneratorMeta.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/TableIdGeneratorMeta.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/TableIdGeneratorMeta.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,117 +1,117 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 6, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.generator; - -import javax.persistence.TableGenerator; - -import org.jiemamy.entity.io.meta.EntityMeta; -import org.jiemamy.entity.io.meta.PropertyMeta; - -/** - * {@link TableGenerator}のメタデータを保持するクラス。 - * - * @author j5ik2o - */ -public class TableIdGeneratorMeta extends AbstractPreAllocateIdGeneratorMeta { - - private String catalogName; - - private String pkColumnName; - - private String pkColumnValue; - - private String valueColumnName; - - private String schemaName; - - private String tableName; - - - /** - * インスタンスを生成する。 - * - * @param entityMeta {@link EntityMeta} - * @param propertyMeta {@link PropertyMeta} - * @param tableGenerator {@link TableGenerator} - */ - public TableIdGeneratorMeta(EntityMeta entityMeta, PropertyMeta propertyMeta, TableGenerator tableGenerator) { - super(entityMeta, propertyMeta, tableGenerator.name(), tableGenerator.initialValue(), tableGenerator - .allocationSize()); - catalogName = tableGenerator.catalog(); - pkColumnName = tableGenerator.pkColumnName(); - pkColumnValue = tableGenerator.pkColumnValue(); - schemaName = tableGenerator.schema(); - tableName = tableGenerator.table(); - } - - /** - * 採番テーブルのカタログ名を取得する。 - * - * @return 採番テーブルのカタログ名 - */ - public String getCatalogName() { - return catalogName; - } - - /** - * 採番テーブルのカラム名を取得する。 - * - * @return 採番テーブルのカラム名 - */ - public String getPkColumnName() { - return pkColumnName; - } - - /** - * 採番テーブルの識別子の値を取得する。 - * - * @return 採番テーブルの識別子の値 - */ - public String getPkColumnValue() { - return pkColumnValue; - } - - /** - * 採番テーブルの識別子の値を取得する。 - * - * @return 採番テーブルの識別子の値 - */ - public String getSchemaName() { - return schemaName; - } - - /** - * 採番テーブル名を取得する。 - * - * @return 採番テーブル名 - */ - public String getTableName() { - return tableName; - } - - /** - * 採番テーブルの値のカラム名を取得する。 - * - * @return 採番テーブルの値のカラム名 - */ - public String getValueColumnName() { - return valueColumnName; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 6, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.generator; + +import javax.persistence.TableGenerator; + +import org.jiemamy.entity.io.meta.EntityMeta; +import org.jiemamy.entity.io.meta.PropertyMeta; + +/** + * {@link TableGenerator}のメタデータを保持するクラス。 + * + * @author j5ik2o + */ +public class TableIdGeneratorMeta extends AbstractPreAllocateIdGeneratorMeta { + + private String catalogName; + + private String pkColumnName; + + private String pkColumnValue; + + private String valueColumnName; + + private String schemaName; + + private String tableName; + + + /** + * インスタンスを生成する。 + * + * @param entityMeta {@link EntityMeta} + * @param propertyMeta {@link PropertyMeta} + * @param tableGenerator {@link TableGenerator} + */ + public TableIdGeneratorMeta(EntityMeta entityMeta, PropertyMeta propertyMeta, TableGenerator tableGenerator) { + super(entityMeta, propertyMeta, tableGenerator.name(), tableGenerator.initialValue(), tableGenerator + .allocationSize()); + catalogName = tableGenerator.catalog(); + pkColumnName = tableGenerator.pkColumnName(); + pkColumnValue = tableGenerator.pkColumnValue(); + schemaName = tableGenerator.schema(); + tableName = tableGenerator.table(); + } + + /** + * 採番テーブルのカタログ名を取得する。 + * + * @return 採番テーブルのカタログ名 + */ + public String getCatalogName() { + return catalogName; + } + + /** + * 採番テーブルのカラム名を取得する。 + * + * @return 採番テーブルのカラム名 + */ + public String getPkColumnName() { + return pkColumnName; + } + + /** + * 採番テーブルの識別子の値を取得する。 + * + * @return 採番テーブルの識別子の値 + */ + public String getPkColumnValue() { + return pkColumnValue; + } + + /** + * 採番テーブルの識別子の値を取得する。 + * + * @return 採番テーブルの識別子の値 + */ + public String getSchemaName() { + return schemaName; + } + + /** + * 採番テーブル名を取得する。 + * + * @return 採番テーブル名 + */ + public String getTableName() { + return tableName; + } + + /** + * 採番テーブルの値のカラム名を取得する。 + * + * @return 採番テーブルの値のカラム名 + */ + public String getValueColumnName() { + return valueColumnName; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/generator/TableIdGeneratorMeta.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/ColumnMetaFactoryImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/ColumnMetaFactoryImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/ColumnMetaFactoryImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,70 +1,70 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 5, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.impl; - -import java.lang.reflect.Field; - -import javax.persistence.Column; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.Validate; - -import org.jiemamy.entity.io.meta.ColumnMeta; -import org.jiemamy.entity.io.meta.ColumnMetaFactory; -import org.jiemamy.entity.io.meta.EntityMeta; -import org.jiemamy.entity.io.meta.PropertyMeta; -import org.jiemamy.utils.JmStringUtil; - -/** - * {@link ColumnMetaFactory}の実装クラス。 - * - * @author j5ik2o - */ -public class ColumnMetaFactoryImpl implements ColumnMetaFactory { - - public ColumnMeta createColumnMeta(Field field, EntityMeta entityMeta, PropertyMeta propertyMeta) { - Validate.notNull(field); - Validate.notNull(entityMeta); - Validate.notNull(propertyMeta); - ColumnMeta columnMeta = new ColumnMeta(); - String defaultName = fromPropertyNameToColumnName(propertyMeta.getName()); - Column column = field.getAnnotation(Column.class); - if (column != null) { - String name = column.name(); - if (StringUtils.isEmpty(name)) { - name = defaultName; - } - columnMeta.setName(name); - columnMeta.setInsertable(column.insertable()); - columnMeta.setUpdatable(column.updatable()); - columnMeta.setNullable(column.nullable()); - columnMeta.setUnique(column.unique()); - columnMeta.setLength(column.length() > 0 ? column.length() : null); - columnMeta.setPrecision(column.precision() > 0 ? column.precision() : null); - } else { - columnMeta.setName(defaultName); - } - return columnMeta; - } - - private String fromPropertyNameToColumnName(String name) { - return JmStringUtil.toSQLName(name); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 5, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.impl; + +import java.lang.reflect.Field; + +import javax.persistence.Column; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.Validate; + +import org.jiemamy.entity.io.meta.ColumnMeta; +import org.jiemamy.entity.io.meta.ColumnMetaFactory; +import org.jiemamy.entity.io.meta.EntityMeta; +import org.jiemamy.entity.io.meta.PropertyMeta; +import org.jiemamy.utils.JmStringUtil; + +/** + * {@link ColumnMetaFactory}の実装クラス。 + * + * @author j5ik2o + */ +public class ColumnMetaFactoryImpl implements ColumnMetaFactory { + + public ColumnMeta createColumnMeta(Field field, EntityMeta entityMeta, PropertyMeta propertyMeta) { + Validate.notNull(field); + Validate.notNull(entityMeta); + Validate.notNull(propertyMeta); + ColumnMeta columnMeta = new ColumnMeta(); + String defaultName = fromPropertyNameToColumnName(propertyMeta.getName()); + Column column = field.getAnnotation(Column.class); + if (column != null) { + String name = column.name(); + if (StringUtils.isEmpty(name)) { + name = defaultName; + } + columnMeta.setName(name); + columnMeta.setInsertable(column.insertable()); + columnMeta.setUpdatable(column.updatable()); + columnMeta.setNullable(column.nullable()); + columnMeta.setUnique(column.unique()); + columnMeta.setLength(column.length() > 0 ? column.length() : null); + columnMeta.setPrecision(column.precision() > 0 ? column.precision() : null); + } else { + columnMeta.setName(defaultName); + } + return columnMeta; + } + + private String fromPropertyNameToColumnName(String name) { + return JmStringUtil.toSQLName(name); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/ColumnMetaFactoryImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityLogicalNameReadCommand.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityLogicalNameReadCommand.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityLogicalNameReadCommand.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,53 +1,53 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 10, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.impl; - -import java.util.List; - -import org.jiemamy.entity.io.annotation.ColumnName; -import org.jiemamy.entity.io.annotation.TableName; -import org.jiemamy.entity.io.meta.EntityMeta; -import org.jiemamy.entity.io.meta.EntityMetaCommand; -import org.jiemamy.entity.io.meta.PropertyMeta; - -/** - * 論理名を読み取って{@link EntityMeta}に設定するコマンドクラス。 - * - * @author j5ik2o - */ -public class EntityLogicalNameReadCommand implements EntityMetaCommand { - - public void execute(List<EntityMeta> entityMetaList) { - for (EntityMeta entityMeta : entityMetaList) { - TableName tn = entityMeta.getEntityClass().getAnnotation(TableName.class); - if (tn != null) { - String tableLogicalName = tn.logical(); - entityMeta.getTableMeta().setLogicalName(tableLogicalName); - } - for (PropertyMeta propertyMeta : entityMeta.getAllColumnPropertyMeta()) { - ColumnName cn = propertyMeta.getField().getAnnotation(ColumnName.class); - if (cn == null) { - continue; - } - String columnLogicalName = cn.logical(); - propertyMeta.getColumnMeta().setLogicalName(columnLogicalName); - } - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 10, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.impl; + +import java.util.List; + +import org.jiemamy.entity.io.annotation.ColumnName; +import org.jiemamy.entity.io.annotation.TableName; +import org.jiemamy.entity.io.meta.EntityMeta; +import org.jiemamy.entity.io.meta.EntityMetaCommand; +import org.jiemamy.entity.io.meta.PropertyMeta; + +/** + * 論理名を読み取って{@link EntityMeta}に設定するコマンドクラス。 + * + * @author j5ik2o + */ +public class EntityLogicalNameReadCommand implements EntityMetaCommand { + + public void execute(List<EntityMeta> entityMetaList) { + for (EntityMeta entityMeta : entityMetaList) { + TableName tn = entityMeta.getEntityClass().getAnnotation(TableName.class); + if (tn != null) { + String tableLogicalName = tn.logical(); + entityMeta.getTableMeta().setLogicalName(tableLogicalName); + } + for (PropertyMeta propertyMeta : entityMeta.getAllColumnPropertyMeta()) { + ColumnName cn = propertyMeta.getField().getAnnotation(ColumnName.class); + if (cn == null) { + continue; + } + String columnLogicalName = cn.logical(); + propertyMeta.getColumnMeta().setLogicalName(columnLogicalName); + } + } + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityLogicalNameReadCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityMetaFactoryImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityMetaFactoryImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityMetaFactoryImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,173 +1,173 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 4, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.impl; - -import java.lang.reflect.Field; -import java.util.concurrent.ConcurrentHashMap; - -import javassist.NotFoundException; - -import javax.persistence.Entity; -import javax.persistence.MappedSuperclass; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.Validate; - -import org.jiemamy.entity.io.meta.CannotCreatePropertyException; -import org.jiemamy.entity.io.meta.ColumnDuplicatedException; -import org.jiemamy.entity.io.meta.EntityMeta; -import org.jiemamy.entity.io.meta.EntityMetaFactory; -import org.jiemamy.entity.io.meta.NonEntityException; -import org.jiemamy.entity.io.meta.PropertyDuplicatedException; -import org.jiemamy.entity.io.meta.PropertyMetaFactory; -import org.jiemamy.entity.io.meta.TableMeta; -import org.jiemamy.entity.io.meta.TableMetaFactory; -import org.jiemamy.entity.io.meta.exception.FieldDuplicatedException; -import org.jiemamy.entity.io.meta.exception.UnsupportedInheritanceException; -import org.jiemamy.utils.ArrayMap; -import org.jiemamy.utils.ClassUtil; -import org.jiemamy.utils.CollectionsUtil; -import org.jiemamy.utils.JmStringUtil; -import org.jiemamy.utils.ModifierUtil; - -/** - * {@link EntityMetaFactory}の実装クラス。 - * - * @author j5ik2o - */ -public class EntityMetaFactoryImpl implements EntityMetaFactory { - - private ConcurrentHashMap<String, EntityMeta> entityMetaCache = CollectionsUtil.newConcurrentHashMap(); - - private TableMetaFactory tableMetaFactory; - - private PropertyMetaFactory propertyMetaFactory; - - - /** - * インスタンスを生成する。 - * - * @param tableMetaFactory テーブルメタファクトリ - * @param propertyMetaFactory プロパティメタファクトリ - */ - public EntityMetaFactoryImpl(TableMetaFactory tableMetaFactory, PropertyMetaFactory propertyMetaFactory) { - Validate.notNull(tableMetaFactory); - Validate.notNull(propertyMetaFactory); - this.tableMetaFactory = tableMetaFactory; - this.propertyMetaFactory = propertyMetaFactory; - } - - private EntityMeta createEntityMeta(Class<?> entityClass) throws NonEntityException { - Validate.notNull(entityClass); - Entity entityAnnotation = entityClass.getAnnotation(Entity.class); - if (entityAnnotation == null) { - throw new NonEntityException(String.format("%s is not entity class.", entityClass.getName())); - } - EntityMeta entityMeta = new EntityMeta(); - doEntityClass(entityMeta, entityClass); - doName(entityMeta, entityAnnotation); - doTableMeta(entityMeta); - try { - doPropertyMeta(entityMeta); - } catch (Exception e) { - throw new NonEntityException(e); - } - //doCustomize(entityMeta); - return entityMeta; - } - - public void dispose() { - entityMetaCache.clear(); - } - - private void doEntityClass(EntityMeta entityMeta, Class<?> entityClass) { - Validate.notNull(entityMeta); - Validate.notNull(entityClass); - entityMeta.setEntityClass(entityClass); - } - - private void doName(EntityMeta entityMeta, Entity entityAnnotation) { - Validate.notNull(entityMeta); - Validate.notNull(entityAnnotation); - String entityName = entityAnnotation.name(); - if (StringUtils.isEmpty(entityName)) { - entityName = JmStringUtil.toUnCapital(entityMeta.getEntityClass().getSimpleName()); - } - entityMeta.setName(entityName); - } - - private void doPropertyMeta(EntityMeta entityMeta) throws ColumnDuplicatedException, PropertyDuplicatedException, - NotFoundException, NoSuchFieldException, UnsupportedInheritanceException, FieldDuplicatedException, - CannotCreatePropertyException { - Validate.notNull(entityMeta); - Field[] fields = getFields(entityMeta.getEntityClass()); - for (Field f : fields) { - f.setAccessible(true); - entityMeta.addPropertyMeta(propertyMetaFactory.createPropertyMeta(entityMeta, f)); - } - } - - private void doTableMeta(EntityMeta entityMeta) { - Validate.notNull(entityMeta); - TableMeta tableMeta = tableMetaFactory.createTableMeta(entityMeta); - entityMeta.setTableMeta(tableMeta); - } - - public EntityMeta getEntityMeta(Class<?> entityClass) throws NonEntityException { - Validate.notNull(entityClass); - EntityMeta entityMeta = entityMetaCache.get(entityClass.getName()); - if (entityMeta != null) { - return entityMeta; - } - entityMeta = createEntityMeta(entityClass); - EntityMeta entityMeta2 = entityMetaCache.putIfAbsent(entityClass.getName(), entityMeta); - return entityMeta2 != null ? entityMeta2 : entityMeta; - } - - private Field[] getFields(Class<?> entityClass) throws NotFoundException, NoSuchFieldException, - UnsupportedInheritanceException, FieldDuplicatedException { - Validate.notNull(entityClass); - ArrayMap<String, Field> fields = new ArrayMap<String, Field>(); - for (Field f : ClassUtil.getDeclaredFields(entityClass)) { - if (!ModifierUtil.isInstanceField(f)) { - continue; - } - fields.put(f.getName(), f); - } - for (Class<?> clazz = entityClass.getSuperclass(); clazz != Object.class; clazz = clazz.getSuperclass()) { - if (clazz.isAnnotationPresent(Entity.class)) { - throw new UnsupportedInheritanceException(entityClass); - } - if (clazz.isAnnotationPresent(MappedSuperclass.class)) { - for (Field f : ClassUtil.getDeclaredFields(clazz)) { - if (ModifierUtil.isInstanceField(f) == false) { - continue; - } - String name = f.getName(); - if (fields.containsKey(name) == false) { - fields.put(name, f); - } else { - throw new FieldDuplicatedException(f); - } - } - } - } - return fields.toArray(new Field[fields.size()]); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 4, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.impl; + +import java.lang.reflect.Field; +import java.util.concurrent.ConcurrentHashMap; + +import javassist.NotFoundException; + +import javax.persistence.Entity; +import javax.persistence.MappedSuperclass; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.Validate; + +import org.jiemamy.entity.io.meta.CannotCreatePropertyException; +import org.jiemamy.entity.io.meta.ColumnDuplicatedException; +import org.jiemamy.entity.io.meta.EntityMeta; +import org.jiemamy.entity.io.meta.EntityMetaFactory; +import org.jiemamy.entity.io.meta.NonEntityException; +import org.jiemamy.entity.io.meta.PropertyDuplicatedException; +import org.jiemamy.entity.io.meta.PropertyMetaFactory; +import org.jiemamy.entity.io.meta.TableMeta; +import org.jiemamy.entity.io.meta.TableMetaFactory; +import org.jiemamy.entity.io.meta.exception.FieldDuplicatedException; +import org.jiemamy.entity.io.meta.exception.UnsupportedInheritanceException; +import org.jiemamy.utils.ArrayMap; +import org.jiemamy.utils.ClassUtil; +import org.jiemamy.utils.CollectionsUtil; +import org.jiemamy.utils.JmStringUtil; +import org.jiemamy.utils.ModifierUtil; + +/** + * {@link EntityMetaFactory}の実装クラス。 + * + * @author j5ik2o + */ +public class EntityMetaFactoryImpl implements EntityMetaFactory { + + private ConcurrentHashMap<String, EntityMeta> entityMetaCache = CollectionsUtil.newConcurrentHashMap(); + + private TableMetaFactory tableMetaFactory; + + private PropertyMetaFactory propertyMetaFactory; + + + /** + * インスタンスを生成する。 + * + * @param tableMetaFactory テーブルメタファクトリ + * @param propertyMetaFactory プロパティメタファクトリ + */ + public EntityMetaFactoryImpl(TableMetaFactory tableMetaFactory, PropertyMetaFactory propertyMetaFactory) { + Validate.notNull(tableMetaFactory); + Validate.notNull(propertyMetaFactory); + this.tableMetaFactory = tableMetaFactory; + this.propertyMetaFactory = propertyMetaFactory; + } + + private EntityMeta createEntityMeta(Class<?> entityClass) throws NonEntityException { + Validate.notNull(entityClass); + Entity entityAnnotation = entityClass.getAnnotation(Entity.class); + if (entityAnnotation == null) { + throw new NonEntityException(String.format("%s is not entity class.", entityClass.getName())); + } + EntityMeta entityMeta = new EntityMeta(); + doEntityClass(entityMeta, entityClass); + doName(entityMeta, entityAnnotation); + doTableMeta(entityMeta); + try { + doPropertyMeta(entityMeta); + } catch (Exception e) { + throw new NonEntityException(e); + } + //doCustomize(entityMeta); + return entityMeta; + } + + public void dispose() { + entityMetaCache.clear(); + } + + private void doEntityClass(EntityMeta entityMeta, Class<?> entityClass) { + Validate.notNull(entityMeta); + Validate.notNull(entityClass); + entityMeta.setEntityClass(entityClass); + } + + private void doName(EntityMeta entityMeta, Entity entityAnnotation) { + Validate.notNull(entityMeta); + Validate.notNull(entityAnnotation); + String entityName = entityAnnotation.name(); + if (StringUtils.isEmpty(entityName)) { + entityName = JmStringUtil.toUnCapital(entityMeta.getEntityClass().getSimpleName()); + } + entityMeta.setName(entityName); + } + + private void doPropertyMeta(EntityMeta entityMeta) throws ColumnDuplicatedException, PropertyDuplicatedException, + NotFoundException, NoSuchFieldException, UnsupportedInheritanceException, FieldDuplicatedException, + CannotCreatePropertyException { + Validate.notNull(entityMeta); + Field[] fields = getFields(entityMeta.getEntityClass()); + for (Field f : fields) { + f.setAccessible(true); + entityMeta.addPropertyMeta(propertyMetaFactory.createPropertyMeta(entityMeta, f)); + } + } + + private void doTableMeta(EntityMeta entityMeta) { + Validate.notNull(entityMeta); + TableMeta tableMeta = tableMetaFactory.createTableMeta(entityMeta); + entityMeta.setTableMeta(tableMeta); + } + + public EntityMeta getEntityMeta(Class<?> entityClass) throws NonEntityException { + Validate.notNull(entityClass); + EntityMeta entityMeta = entityMetaCache.get(entityClass.getName()); + if (entityMeta != null) { + return entityMeta; + } + entityMeta = createEntityMeta(entityClass); + EntityMeta entityMeta2 = entityMetaCache.putIfAbsent(entityClass.getName(), entityMeta); + return entityMeta2 != null ? entityMeta2 : entityMeta; + } + + private Field[] getFields(Class<?> entityClass) throws NotFoundException, NoSuchFieldException, + UnsupportedInheritanceException, FieldDuplicatedException { + Validate.notNull(entityClass); + ArrayMap<String, Field> fields = new ArrayMap<String, Field>(); + for (Field f : ClassUtil.getDeclaredFields(entityClass)) { + if (!ModifierUtil.isInstanceField(f)) { + continue; + } + fields.put(f.getName(), f); + } + for (Class<?> clazz = entityClass.getSuperclass(); clazz != Object.class; clazz = clazz.getSuperclass()) { + if (clazz.isAnnotationPresent(Entity.class)) { + throw new UnsupportedInheritanceException(entityClass); + } + if (clazz.isAnnotationPresent(MappedSuperclass.class)) { + for (Field f : ClassUtil.getDeclaredFields(clazz)) { + if (ModifierUtil.isInstanceField(f) == false) { + continue; + } + String name = f.getName(); + if (fields.containsKey(name) == false) { + fields.put(name, f); + } else { + throw new FieldDuplicatedException(f); + } + } + } + } + return fields.toArray(new Field[fields.size()]); + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityMetaFactoryImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityMetaReaderImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityMetaReaderImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityMetaReaderImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,190 +1,190 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 3, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.impl; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Pattern; - -import javax.persistence.Entity; - -import org.apache.commons.lang.Validate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.jiemamy.entity.io.meta.EntityClassNotFoundException; -import org.jiemamy.entity.io.meta.EntityMeta; -import org.jiemamy.entity.io.meta.EntityMetaCommand; -import org.jiemamy.entity.io.meta.EntityMetaFactory; -import org.jiemamy.entity.io.meta.EntityMetaReader; -import org.jiemamy.entity.io.meta.EntityMetaReaderContext; -import org.jiemamy.entity.io.meta.NonEntityException; -import org.jiemamy.utils.ClassLoaderUtil; -import org.jiemamy.utils.ClassTraversal; -import org.jiemamy.utils.ClassUtil; -import org.jiemamy.utils.CollectionsUtil; -import org.jiemamy.utils.FileUtil; -import org.jiemamy.utils.LogMarker; -import org.jiemamy.utils.TraversalHandlerException; -import org.jiemamy.utils.ClassTraversal.ClassHandler; - -/** - * {@link EntityMetaReader}の実装クラス。 - * - * @author j5ik2o - */ -public class EntityMetaReaderImpl implements EntityMetaReader { - - private static final Logger LOG = LoggerFactory.getLogger(EntityMetaReaderImpl.class); - - private final EntityMetaReaderContext entityMetaReaderContext; - - private EntityMetaCommand logicalNameReadCommand = new EntityLogicalNameReadCommand(); - - - /** - * インスタンスを生成する。 - * - * @param entityMetaReaderContext コンテキスト - */ - public EntityMetaReaderImpl(EntityMetaReaderContext entityMetaReaderContext) { - Validate.notNull(entityMetaReaderContext); - Validate.notNull(entityMetaReaderContext.getClassPathDirs()); - Validate.notEmpty(entityMetaReaderContext.getClassPathDirs()); - Validate.notNull(entityMetaReaderContext.getJavaFileEncoding()); - Validate.notNull(entityMetaReaderContext.getPackageName()); - Validate.notNull(entityMetaReaderContext.getEntityMetaFactory()); - this.entityMetaReaderContext = entityMetaReaderContext; - } - - /** - * クラスローダを生成する。 - * - * @return {@link ClassLoader} - * @throws IOException 入出力が失敗した場合 - */ - private ClassLoader createClassLoader() throws IOException { - List<URL> urlList = toURLs(entityMetaReaderContext.getClassPathDirs()); - final URLClassLoader urlClassLoader = new URLClassLoader(urlList.toArray(new URL[urlList.size()])); - return urlClassLoader; - } - - private boolean isIgnoreShortClassName(String shortClassName) { - Validate.notNull(shortClassName); - if (entityMetaReaderContext.getIgnoreShortClassNamePatterns().isEmpty()) { - return false; - } - for (Pattern pattern : entityMetaReaderContext.getIgnoreShortClassNamePatterns()) { - if (pattern.matcher(shortClassName).matches()) { - return true; - } - } - return false; - } - - private boolean isShortClassName(String shortClassName) { - Validate.notNull(shortClassName); - if (entityMetaReaderContext.getShortClassNamePatterns().isEmpty()) { - return true; - } - for (Pattern pattern : entityMetaReaderContext.getShortClassNamePatterns()) { - if (pattern.matcher(shortClassName).matches()) { - return true; - } - } - return false; - - } - - public List<EntityMeta> read() throws IOException, EntityClassNotFoundException { - final EntityMetaFactory factory = entityMetaReaderContext.getEntityMetaFactory(); - try { - final List<EntityMeta> entityMetas = CollectionsUtil.newArrayList(); - final String entityFullPackageName = entityMetaReaderContext.getPackageName(); - final ClassLoader classLoader = createClassLoader(); - for (File classPathDir : entityMetaReaderContext.getClassPathDirs()) { - - try { - ClassTraversal.forEach(classPathDir, new ClassHandler() { - - public void processClass(String packageName, String shortClassName) - throws TraversalHandlerException { - if (packageName.equals(entityFullPackageName) == false) { - return; - } - if (isIgnoreShortClassName(shortClassName)) { - return; - } - if (isShortClassName(shortClassName) == false) { - return; - } - try { - String entityClassName = ClassUtil.concatName(packageName, shortClassName); - Class<?> entityClass = ClassLoaderUtil.loadClass(classLoader, entityClassName); - if (entityClass.isAnnotationPresent(Entity.class)) { - EntityMeta entityMeta = factory.getEntityMeta(entityClass); - LOG.debug(LogMarker.DETAIL, entityClassName); - entityMetas.add(entityMeta); - } - } catch (ClassNotFoundException e) { - throw new TraversalHandlerException(e); - } catch (NonEntityException e) { - throw new TraversalHandlerException(e); - } - } - }); - } catch (TraversalHandlerException e) { - throw new IOException(); - } - } - if (entityMetas.isEmpty()) { - throw new EntityClassNotFoundException(); - } - if (entityMetaReaderContext.isReadComment()) { - readComment(entityMetas); - } - return entityMetas; - } finally { - factory.dispose(); - } - } - - /** - * コメントを読みコメントをメタデータに設定する。 - * - * @param entityMetaList エンティティメタデータのリスト - * @throws IOException 入出力が失敗した場合 - */ - protected void readComment(List<EntityMeta> entityMetaList) throws IOException { - logicalNameReadCommand.execute(entityMetaList); - } - - private List<URL> toURLs(List<File> files) throws MalformedURLException { - List<URL> urlList = new ArrayList<URL>(); - for (File classPathDir : entityMetaReaderContext.getClassPathDirs()) { - urlList.add(FileUtil.toURL(classPathDir)); - } - return urlList; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 3, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.impl; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; + +import javax.persistence.Entity; + +import org.apache.commons.lang.Validate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jiemamy.entity.io.meta.EntityClassNotFoundException; +import org.jiemamy.entity.io.meta.EntityMeta; +import org.jiemamy.entity.io.meta.EntityMetaCommand; +import org.jiemamy.entity.io.meta.EntityMetaFactory; +import org.jiemamy.entity.io.meta.EntityMetaReader; +import org.jiemamy.entity.io.meta.EntityMetaReaderContext; +import org.jiemamy.entity.io.meta.NonEntityException; +import org.jiemamy.utils.ClassLoaderUtil; +import org.jiemamy.utils.ClassTraversal; +import org.jiemamy.utils.ClassUtil; +import org.jiemamy.utils.CollectionsUtil; +import org.jiemamy.utils.FileUtil; +import org.jiemamy.utils.LogMarker; +import org.jiemamy.utils.TraversalHandlerException; +import org.jiemamy.utils.ClassTraversal.ClassHandler; + +/** + * {@link EntityMetaReader}の実装クラス。 + * + * @author j5ik2o + */ +public class EntityMetaReaderImpl implements EntityMetaReader { + + private static final Logger LOG = LoggerFactory.getLogger(EntityMetaReaderImpl.class); + + private final EntityMetaReaderContext entityMetaReaderContext; + + private EntityMetaCommand logicalNameReadCommand = new EntityLogicalNameReadCommand(); + + + /** + * インスタンスを生成する。 + * + * @param entityMetaReaderContext コンテキスト + */ + public EntityMetaReaderImpl(EntityMetaReaderContext entityMetaReaderContext) { + Validate.notNull(entityMetaReaderContext); + Validate.notNull(entityMetaReaderContext.getClassPathDirs()); + Validate.notEmpty(entityMetaReaderContext.getClassPathDirs()); + Validate.notNull(entityMetaReaderContext.getJavaFileEncoding()); + Validate.notNull(entityMetaReaderContext.getPackageName()); + Validate.notNull(entityMetaReaderContext.getEntityMetaFactory()); + this.entityMetaReaderContext = entityMetaReaderContext; + } + + /** + * クラスローダを生成する。 + * + * @return {@link ClassLoader} + * @throws IOException 入出力が失敗した場合 + */ + private ClassLoader createClassLoader() throws IOException { + List<URL> urlList = toURLs(entityMetaReaderContext.getClassPathDirs()); + final URLClassLoader urlClassLoader = new URLClassLoader(urlList.toArray(new URL[urlList.size()])); + return urlClassLoader; + } + + private boolean isIgnoreShortClassName(String shortClassName) { + Validate.notNull(shortClassName); + if (entityMetaReaderContext.getIgnoreShortClassNamePatterns().isEmpty()) { + return false; + } + for (Pattern pattern : entityMetaReaderContext.getIgnoreShortClassNamePatterns()) { + if (pattern.matcher(shortClassName).matches()) { + return true; + } + } + return false; + } + + private boolean isShortClassName(String shortClassName) { + Validate.notNull(shortClassName); + if (entityMetaReaderContext.getShortClassNamePatterns().isEmpty()) { + return true; + } + for (Pattern pattern : entityMetaReaderContext.getShortClassNamePatterns()) { + if (pattern.matcher(shortClassName).matches()) { + return true; + } + } + return false; + + } + + public List<EntityMeta> read() throws IOException, EntityClassNotFoundException { + final EntityMetaFactory factory = entityMetaReaderContext.getEntityMetaFactory(); + try { + final List<EntityMeta> entityMetas = CollectionsUtil.newArrayList(); + final String entityFullPackageName = entityMetaReaderContext.getPackageName(); + final ClassLoader classLoader = createClassLoader(); + for (File classPathDir : entityMetaReaderContext.getClassPathDirs()) { + + try { + ClassTraversal.forEach(classPathDir, new ClassHandler() { + + public void processClass(String packageName, String shortClassName) + throws TraversalHandlerException { + if (packageName.equals(entityFullPackageName) == false) { + return; + } + if (isIgnoreShortClassName(shortClassName)) { + return; + } + if (isShortClassName(shortClassName) == false) { + return; + } + try { + String entityClassName = ClassUtil.concatName(packageName, shortClassName); + Class<?> entityClass = ClassLoaderUtil.loadClass(classLoader, entityClassName); + if (entityClass.isAnnotationPresent(Entity.class)) { + EntityMeta entityMeta = factory.getEntityMeta(entityClass); + LOG.debug(LogMarker.DETAIL, entityClassName); + entityMetas.add(entityMeta); + } + } catch (ClassNotFoundException e) { + throw new TraversalHandlerException(e); + } catch (NonEntityException e) { + throw new TraversalHandlerException(e); + } + } + }); + } catch (TraversalHandlerException e) { + throw new IOException(); + } + } + if (entityMetas.isEmpty()) { + throw new EntityClassNotFoundException(); + } + if (entityMetaReaderContext.isReadComment()) { + readComment(entityMetas); + } + return entityMetas; + } finally { + factory.dispose(); + } + } + + /** + * コメントを読みコメントをメタデータに設定する。 + * + * @param entityMetaList エンティティメタデータのリスト + * @throws IOException 入出力が失敗した場合 + */ + protected void readComment(List<EntityMeta> entityMetaList) throws IOException { + logicalNameReadCommand.execute(entityMetaList); + } + + private List<URL> toURLs(List<File> files) throws MalformedURLException { + List<URL> urlList = new ArrayList<URL>(); + for (File classPathDir : entityMetaReaderContext.getClassPathDirs()) { + urlList.add(FileUtil.toURL(classPathDir)); + } + return urlList; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityMetaReaderImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/PropertyMetaFactoryImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/PropertyMetaFactoryImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/PropertyMetaFactoryImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,467 +1,467 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 5, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.impl; - -import java.lang.reflect.Field; -import java.util.Calendar; -import java.util.List; - -import javax.persistence.Basic; -import javax.persistence.Entity; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinColumns; -import javax.persistence.Lob; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.OneToOne; -import javax.persistence.SequenceGenerator; -import javax.persistence.TableGenerator; -import javax.persistence.Temporal; -import javax.persistence.Transient; -import javax.persistence.Version; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.Validate; - -import org.jiemamy.entity.io.meta.CannotCreatePropertyException; -import org.jiemamy.entity.io.meta.ColumnMetaFactory; -import org.jiemamy.entity.io.meta.EntityMeta; -import org.jiemamy.entity.io.meta.JoinColumnMeta; -import org.jiemamy.entity.io.meta.PropertyMeta; -import org.jiemamy.entity.io.meta.PropertyMetaFactory; -import org.jiemamy.entity.io.meta.RelationshipType; -import org.jiemamy.entity.io.meta.exception.BothMappedByAndJoinColumnException; -import org.jiemamy.entity.io.meta.exception.IdGeneratorNotFoundException; -import org.jiemamy.entity.io.meta.exception.JoinColumnNameAndReferencedColumnNameMandatoryException; -import org.jiemamy.entity.io.meta.exception.LazyFetchSpecifiedException; -import org.jiemamy.entity.io.meta.exception.MappedByMandatoryException; -import org.jiemamy.entity.io.meta.exception.OneToManyNotGenericsException; -import org.jiemamy.entity.io.meta.exception.OneToManyNotListException; -import org.jiemamy.entity.io.meta.exception.RelationshipNotEntityException; -import org.jiemamy.entity.io.meta.exception.TemporalTypeNotSpecifiedException; -import org.jiemamy.entity.io.meta.exception.UnsupportedRelationshipException; -import org.jiemamy.entity.io.meta.exception.VersionPropertyNotNumberException; -import org.jiemamy.entity.io.meta.generator.IdentityIdGeneratorMeta; -import org.jiemamy.entity.io.meta.generator.SequenceIdGeneratorMeta; -import org.jiemamy.entity.io.meta.generator.TableIdGeneratorMeta; -import org.jiemamy.utils.ClassUtil; -import org.jiemamy.utils.ModifierUtil; -import org.jiemamy.utils.ReflectionUtil; - -/** - * {@link PropertyMetaFactory}の実装クラス。 - * - * @author j5ik2o - */ -public class PropertyMetaFactoryImpl implements PropertyMetaFactory { - - private ColumnMetaFactory columnMetaFactory; - - /** デフォルトの{@link SequenceGenerator} */ - protected static final SequenceGenerator DEFAULT_SEQUENCE_GENERATOR = - PropertyMetaFactoryImpl.class.getAnnotation(SequenceGenerator.class); - - /** デフォルトの{@link TableGenerator} */ - protected static final TableGenerator DEFAULT_TABLE_GENERATOR = - PropertyMetaFactoryImpl.class.getAnnotation(TableGenerator.class); - - - /** - * インスタンスを生成する。 - * - * @param columnMetaFactory {@link ColumnMetaFactory} - */ - public PropertyMetaFactoryImpl(ColumnMetaFactory columnMetaFactory) { - Validate.notNull(columnMetaFactory); - this.columnMetaFactory = columnMetaFactory; - } - - public PropertyMeta createPropertyMeta(EntityMeta entityMeta, Field field) throws CannotCreatePropertyException { - Validate.notNull(field); - Validate.notNull(entityMeta); - PropertyMeta propertyMeta = new PropertyMeta(); - doField(propertyMeta, field, entityMeta); - doName(propertyMeta, field, entityMeta); - doTransient(propertyMeta, field, entityMeta); - if (propertyMeta.isTransient() == false) { - Object relationshipAnnotation = getRelationshipAnnotation(field); - if (relationshipAnnotation == null) { - doColumnMeta(propertyMeta, field, entityMeta); - try { - doId(propertyMeta, field, entityMeta); - doFetchType(propertyMeta, field, entityMeta); - doTemporal(propertyMeta, field, entityMeta); - doEnum(propertyMeta, field, entityMeta); - doVersion(propertyMeta, field, entityMeta); - doLob(propertyMeta, field, entityMeta); - } catch (Throwable t) { - throw new CannotCreatePropertyException(t); - } - - } else { - try { - doRelationship(propertyMeta, field, entityMeta, relationshipAnnotation); - } catch (Throwable t) { - throw new CannotCreatePropertyException(t); - } - } - } - doCustomize(propertyMeta, field, entityMeta); - return propertyMeta; - - } - - private void doColumnMeta(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - propertyMeta.setColumnMeta(columnMetaFactory.createColumnMeta(field, entityMeta, propertyMeta)); - } - - private void doCustomize(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { - // TODO Auto-generated method stub - } - - private void doEnum(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - if (propertyMeta.getPropertyClass().isEnum() == false) { - return; - } - Enumerated enumerated = field.getAnnotation(Enumerated.class); - if (enumerated == null) { - return; - } - propertyMeta.setEnumType(enumerated.value()); - } - - private void doFetchType(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) - throws LazyFetchSpecifiedException { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - final Basic basic = field.getAnnotation(Basic.class); - if (basic == null) { - propertyMeta.setFetchType(FetchType.EAGER); - return; - } - if (propertyMeta.isId() && basic.fetch() == FetchType.LAZY) { - throw new LazyFetchSpecifiedException(entityMeta.getName(), propertyMeta.getName()); - } - propertyMeta.setFetchType(basic.fetch()); - } - - private void doField(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - propertyMeta.setField(field); - propertyMeta.setPropertyClass(field.getType()); - } - - private void doId(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) - throws IdGeneratorNotFoundException { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - propertyMeta.setId(field.getAnnotation(Id.class) != null); - GeneratedValue generatedValue = field.getAnnotation(GeneratedValue.class); - if (generatedValue == null) { - return; - } - GenerationType generationType = generatedValue.strategy(); - propertyMeta.setGenerationType(generationType); - switch (generationType) { - case AUTO: - doIdentityIdGenerator(propertyMeta, entityMeta); - doSequenceIdGenerator(propertyMeta, generatedValue, entityMeta); - doTableIdGenerator(propertyMeta, generatedValue, entityMeta); - break; - case IDENTITY: - doIdentityIdGenerator(propertyMeta, entityMeta); - break; - case SEQUENCE: - if (!doSequenceIdGenerator(propertyMeta, generatedValue, entityMeta)) { - throw new IdGeneratorNotFoundException(entityMeta.getName(), propertyMeta.getName(), generatedValue - .generator()); - } - break; - case TABLE: - if (!doTableIdGenerator(propertyMeta, generatedValue, entityMeta)) { - throw new IdGeneratorNotFoundException(entityMeta.getName(), propertyMeta.getName(), generatedValue - .generator()); - } - break; - default: - } - } - - private void doIdentityIdGenerator(PropertyMeta propertyMeta, EntityMeta entityMeta) { - Validate.notNull(propertyMeta); - Validate.notNull(entityMeta); - propertyMeta.setIdentityIdGenerator(new IdentityIdGeneratorMeta(entityMeta, propertyMeta)); - } - - private void doJoinColumn(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) - throws JoinColumnNameAndReferencedColumnNameMandatoryException { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - JoinColumn joinColumn = field.getAnnotation(JoinColumn.class); - if (joinColumn != null) { - JoinColumnMeta meta = new JoinColumnMeta(joinColumn.name(), joinColumn.referencedColumnName()); - propertyMeta.addJoinColumnMeta(meta); - } else { - JoinColumns joinColumns = field.getAnnotation(JoinColumns.class); - if (joinColumns != null) { - JoinColumn[] array = joinColumns.value(); - for (int i = 0; i < array.length; i++) { - JoinColumn jc = array[i]; - JoinColumnMeta meta = new JoinColumnMeta(jc.name(), jc.referencedColumnName()); - if (i > 0 && (meta.getName() == null || meta.getReferencedColumnName() == null)) { - throw new JoinColumnNameAndReferencedColumnNameMandatoryException(entityMeta.getName(), - propertyMeta.getName(), i + 1); - } - propertyMeta.addJoinColumnMeta(meta); - } - } - } - } - - private void doLob(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - propertyMeta.setLob(field.getAnnotation(Lob.class) != null); - } - - private void doManyToOne(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta, ManyToOne manyToOne) - throws RelationshipNotEntityException { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - Validate.notNull(manyToOne); - propertyMeta.setRelationshipType(RelationshipType.MANY_TO_ONE); - Class<?> relationshipClass = field.getType(); - if (relationshipClass.getAnnotation(Entity.class) == null) { - throw new RelationshipNotEntityException(entityMeta.getName(), propertyMeta.getName(), relationshipClass); - } - propertyMeta.setRelationshipClass(relationshipClass); - } - - private void doName(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - propertyMeta.setName(fromFieldNameToPropertyName(field.getName())); - } - - private void doOneToMany(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta, OneToMany oneToMany) - throws OneToManyNotListException, OneToManyNotGenericsException, RelationshipNotEntityException, - BothMappedByAndJoinColumnException, MappedByMandatoryException { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - Validate.notNull(oneToMany); - propertyMeta.setRelationshipType(RelationshipType.ONE_TO_MANY); - if (List.class.isAssignableFrom(field.getType()) == false) { - throw new OneToManyNotListException(entityMeta.getName(), propertyMeta.getName()); - } - Class<?> relationshipClass = ReflectionUtil.getElementTypeOfList(field.getGenericType()); - if (relationshipClass == null) { - throw new OneToManyNotGenericsException(entityMeta.getName(), propertyMeta.getName()); - } - if (relationshipClass.getAnnotation(Entity.class) == null) { - throw new RelationshipNotEntityException(entityMeta.getName(), propertyMeta.getName(), relationshipClass); - } - propertyMeta.setRelationshipClass(relationshipClass); - String mappedBy = oneToMany.mappedBy(); - if (!StringUtils.isEmpty(mappedBy)) { - if (propertyMeta.getJoinColumnMetaList().size() > 0) { - throw new BothMappedByAndJoinColumnException(entityMeta.getName(), propertyMeta.getName()); - } - propertyMeta.setMappedBy(mappedBy); - } else { - throw new MappedByMandatoryException(entityMeta.getName(), propertyMeta.getName()); - } - } - - private void doOneToOne(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta, OneToOne oneToOne) - throws RelationshipNotEntityException, BothMappedByAndJoinColumnException { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - Validate.notNull(oneToOne); - propertyMeta.setRelationshipType(RelationshipType.ONE_TO_ONE); - Class<?> relationshipClass = field.getType(); - if (relationshipClass.getAnnotation(Entity.class) == null) { - throw new RelationshipNotEntityException(entityMeta.getName(), propertyMeta.getName(), relationshipClass); - } - propertyMeta.setRelationshipClass(relationshipClass); - String mappedBy = oneToOne.mappedBy(); - if (!StringUtils.isEmpty(mappedBy)) { - if (propertyMeta.getJoinColumnMetaList().size() > 0) { - throw new BothMappedByAndJoinColumnException(entityMeta.getName(), propertyMeta.getName()); - } - propertyMeta.setMappedBy(mappedBy); - } - } - - private void doRelationship(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta, - Object relationshipAnnotation) throws UnsupportedRelationshipException, - JoinColumnNameAndReferencedColumnNameMandatoryException, RelationshipNotEntityException, - BothMappedByAndJoinColumnException, OneToManyNotListException, OneToManyNotGenericsException, - MappedByMandatoryException { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - Validate.notNull(relationshipAnnotation); - doJoinColumn(propertyMeta, field, entityMeta); - if (OneToOne.class.isInstance(relationshipAnnotation)) { - doOneToOne(propertyMeta, field, entityMeta, OneToOne.class.cast(relationshipAnnotation)); - } else if (OneToMany.class.isInstance(relationshipAnnotation)) { - doOneToMany(propertyMeta, field, entityMeta, OneToMany.class.cast(relationshipAnnotation)); - } else if (ManyToOne.class.isInstance(relationshipAnnotation)) { - doManyToOne(propertyMeta, field, entityMeta, ManyToOne.class.cast(relationshipAnnotation)); - } else { - throw new UnsupportedRelationshipException(entityMeta.getName(), propertyMeta.getName()); - } - } - - private boolean doSequenceIdGenerator(PropertyMeta propertyMeta, GeneratedValue generatedValue, - EntityMeta entityMeta) { - Validate.notNull(propertyMeta); - Validate.notNull(generatedValue); - Validate.notNull(entityMeta); - String name = generatedValue.generator(); - SequenceGenerator sequenceGenerator; - if (StringUtils.isEmpty(name)) { - sequenceGenerator = DEFAULT_SEQUENCE_GENERATOR; - } else { - sequenceGenerator = propertyMeta.getField().getAnnotation(SequenceGenerator.class); - if (sequenceGenerator == null || !name.equals(sequenceGenerator.name())) { - sequenceGenerator = entityMeta.getEntityClass().getAnnotation(SequenceGenerator.class); - if (sequenceGenerator == null || !name.equals(sequenceGenerator.name())) { - return false; - } - } - } - propertyMeta.setSequenceIdGenerator(new SequenceIdGeneratorMeta(entityMeta, propertyMeta, sequenceGenerator)); - return true; - } - - private boolean doTableIdGenerator(PropertyMeta propertyMeta, GeneratedValue generatedValue, EntityMeta entityMeta) { - Validate.notNull(propertyMeta); - Validate.notNull(generatedValue); - Validate.notNull(entityMeta); - String name = generatedValue.generator(); - TableGenerator tableGenerator; - if (StringUtils.isEmpty(name)) { - tableGenerator = DEFAULT_TABLE_GENERATOR; - } else { - tableGenerator = propertyMeta.getField().getAnnotation(TableGenerator.class); - if (tableGenerator == null || !name.equals(tableGenerator.name())) { - tableGenerator = entityMeta.getEntityClass().getAnnotation(TableGenerator.class); - if (tableGenerator == null || !name.equals(tableGenerator.name())) { - return false; - } - } - } - propertyMeta.setTableIdGenerator(new TableIdGeneratorMeta(entityMeta, propertyMeta, tableGenerator)); - return true; - } - - private void doTemporal(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) - throws TemporalTypeNotSpecifiedException { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - if (propertyMeta.getPropertyClass() != java.util.Date.class - && propertyMeta.getPropertyClass() != Calendar.class) { - return; - } - Temporal temporal = field.getAnnotation(Temporal.class); - if (temporal == null) { - throw new TemporalTypeNotSpecifiedException(entityMeta.getName(), propertyMeta.getName()); - } - propertyMeta.setTemporalType(temporal.value()); - } - - private void doTransient(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - propertyMeta.setTransient(field.getAnnotation(Transient.class) != null || ModifierUtil.isTransient(field)); - } - - private void doVersion(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) - throws VersionPropertyNotNumberException { - Validate.notNull(propertyMeta); - Validate.notNull(field); - Validate.notNull(entityMeta); - if (field.getAnnotation(Version.class) == null) { - return; - } - Class<?> clazz = ClassUtil.getWrapperClassIfPrimitive(field.getType()); - if (clazz != Integer.class && clazz != Long.class && clazz != int.class && clazz != long.class) { - throw new VersionPropertyNotNumberException(entityMeta.getName(), propertyMeta.getName()); - } - propertyMeta.setVersion(true); - } - - private String fromFieldNameToPropertyName(String name) { - Validate.notNull(name); - return name; - } - - /** - * フィールドに関連のアノテーションが指定されていればそれを取得する。 - * - * @param field フィールド - * @return 関連のアノテーションまたは<code>null</code> - */ - protected Object getRelationshipAnnotation(Field field) { - Validate.notNull(field); - final OneToOne oneToOne = field.getAnnotation(OneToOne.class); - if (oneToOne != null) { - return oneToOne; - } - final OneToMany oneToMany = field.getAnnotation(OneToMany.class); - if (oneToMany != null) { - return oneToMany; - } - final ManyToOne manyToOne = field.getAnnotation(ManyToOne.class); - if (manyToOne != null) { - return manyToOne; - } - final ManyToMany manyToMany = field.getAnnotation(ManyToMany.class); - if (manyToMany != null) { - return manyToMany; - } - return null; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 5, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.impl; + +import java.lang.reflect.Field; +import java.util.Calendar; +import java.util.List; + +import javax.persistence.Basic; +import javax.persistence.Entity; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.Lob; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; +import javax.persistence.SequenceGenerator; +import javax.persistence.TableGenerator; +import javax.persistence.Temporal; +import javax.persistence.Transient; +import javax.persistence.Version; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.Validate; + +import org.jiemamy.entity.io.meta.CannotCreatePropertyException; +import org.jiemamy.entity.io.meta.ColumnMetaFactory; +import org.jiemamy.entity.io.meta.EntityMeta; +import org.jiemamy.entity.io.meta.JoinColumnMeta; +import org.jiemamy.entity.io.meta.PropertyMeta; +import org.jiemamy.entity.io.meta.PropertyMetaFactory; +import org.jiemamy.entity.io.meta.RelationshipType; +import org.jiemamy.entity.io.meta.exception.BothMappedByAndJoinColumnException; +import org.jiemamy.entity.io.meta.exception.IdGeneratorNotFoundException; +import org.jiemamy.entity.io.meta.exception.JoinColumnNameAndReferencedColumnNameMandatoryException; +import org.jiemamy.entity.io.meta.exception.LazyFetchSpecifiedException; +import org.jiemamy.entity.io.meta.exception.MappedByMandatoryException; +import org.jiemamy.entity.io.meta.exception.OneToManyNotGenericsException; +import org.jiemamy.entity.io.meta.exception.OneToManyNotListException; +import org.jiemamy.entity.io.meta.exception.RelationshipNotEntityException; +import org.jiemamy.entity.io.meta.exception.TemporalTypeNotSpecifiedException; +import org.jiemamy.entity.io.meta.exception.UnsupportedRelationshipException; +import org.jiemamy.entity.io.meta.exception.VersionPropertyNotNumberException; +import org.jiemamy.entity.io.meta.generator.IdentityIdGeneratorMeta; +import org.jiemamy.entity.io.meta.generator.SequenceIdGeneratorMeta; +import org.jiemamy.entity.io.meta.generator.TableIdGeneratorMeta; +import org.jiemamy.utils.ClassUtil; +import org.jiemamy.utils.ModifierUtil; +import org.jiemamy.utils.ReflectionUtil; + +/** + * {@link PropertyMetaFactory}の実装クラス。 + * + * @author j5ik2o + */ +public class PropertyMetaFactoryImpl implements PropertyMetaFactory { + + private ColumnMetaFactory columnMetaFactory; + + /** デフォルトの{@link SequenceGenerator} */ + protected static final SequenceGenerator DEFAULT_SEQUENCE_GENERATOR = + PropertyMetaFactoryImpl.class.getAnnotation(SequenceGenerator.class); + + /** デフォルトの{@link TableGenerator} */ + protected static final TableGenerator DEFAULT_TABLE_GENERATOR = + PropertyMetaFactoryImpl.class.getAnnotation(TableGenerator.class); + + + /** + * インスタンスを生成する。 + * + * @param columnMetaFactory {@link ColumnMetaFactory} + */ + public PropertyMetaFactoryImpl(ColumnMetaFactory columnMetaFactory) { + Validate.notNull(columnMetaFactory); + this.columnMetaFactory = columnMetaFactory; + } + + public PropertyMeta createPropertyMeta(EntityMeta entityMeta, Field field) throws CannotCreatePropertyException { + Validate.notNull(field); + Validate.notNull(entityMeta); + PropertyMeta propertyMeta = new PropertyMeta(); + doField(propertyMeta, field, entityMeta); + doName(propertyMeta, field, entityMeta); + doTransient(propertyMeta, field, entityMeta); + if (propertyMeta.isTransient() == false) { + Object relationshipAnnotation = getRelationshipAnnotation(field); + if (relationshipAnnotation == null) { + doColumnMeta(propertyMeta, field, entityMeta); + try { + doId(propertyMeta, field, entityMeta); + doFetchType(propertyMeta, field, entityMeta); + doTemporal(propertyMeta, field, entityMeta); + doEnum(propertyMeta, field, entityMeta); + doVersion(propertyMeta, field, entityMeta); + doLob(propertyMeta, field, entityMeta); + } catch (Throwable t) { + throw new CannotCreatePropertyException(t); + } + + } else { + try { + doRelationship(propertyMeta, field, entityMeta, relationshipAnnotation); + } catch (Throwable t) { + throw new CannotCreatePropertyException(t); + } + } + } + doCustomize(propertyMeta, field, entityMeta); + return propertyMeta; + + } + + private void doColumnMeta(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + propertyMeta.setColumnMeta(columnMetaFactory.createColumnMeta(field, entityMeta, propertyMeta)); + } + + private void doCustomize(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { + // TODO Auto-generated method stub + } + + private void doEnum(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + if (propertyMeta.getPropertyClass().isEnum() == false) { + return; + } + Enumerated enumerated = field.getAnnotation(Enumerated.class); + if (enumerated == null) { + return; + } + propertyMeta.setEnumType(enumerated.value()); + } + + private void doFetchType(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) + throws LazyFetchSpecifiedException { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + final Basic basic = field.getAnnotation(Basic.class); + if (basic == null) { + propertyMeta.setFetchType(FetchType.EAGER); + return; + } + if (propertyMeta.isId() && basic.fetch() == FetchType.LAZY) { + throw new LazyFetchSpecifiedException(entityMeta.getName(), propertyMeta.getName()); + } + propertyMeta.setFetchType(basic.fetch()); + } + + private void doField(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + propertyMeta.setField(field); + propertyMeta.setPropertyClass(field.getType()); + } + + private void doId(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) + throws IdGeneratorNotFoundException { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + propertyMeta.setId(field.getAnnotation(Id.class) != null); + GeneratedValue generatedValue = field.getAnnotation(GeneratedValue.class); + if (generatedValue == null) { + return; + } + GenerationType generationType = generatedValue.strategy(); + propertyMeta.setGenerationType(generationType); + switch (generationType) { + case AUTO: + doIdentityIdGenerator(propertyMeta, entityMeta); + doSequenceIdGenerator(propertyMeta, generatedValue, entityMeta); + doTableIdGenerator(propertyMeta, generatedValue, entityMeta); + break; + case IDENTITY: + doIdentityIdGenerator(propertyMeta, entityMeta); + break; + case SEQUENCE: + if (!doSequenceIdGenerator(propertyMeta, generatedValue, entityMeta)) { + throw new IdGeneratorNotFoundException(entityMeta.getName(), propertyMeta.getName(), generatedValue + .generator()); + } + break; + case TABLE: + if (!doTableIdGenerator(propertyMeta, generatedValue, entityMeta)) { + throw new IdGeneratorNotFoundException(entityMeta.getName(), propertyMeta.getName(), generatedValue + .generator()); + } + break; + default: + } + } + + private void doIdentityIdGenerator(PropertyMeta propertyMeta, EntityMeta entityMeta) { + Validate.notNull(propertyMeta); + Validate.notNull(entityMeta); + propertyMeta.setIdentityIdGenerator(new IdentityIdGeneratorMeta(entityMeta, propertyMeta)); + } + + private void doJoinColumn(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) + throws JoinColumnNameAndReferencedColumnNameMandatoryException { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + JoinColumn joinColumn = field.getAnnotation(JoinColumn.class); + if (joinColumn != null) { + JoinColumnMeta meta = new JoinColumnMeta(joinColumn.name(), joinColumn.referencedColumnName()); + propertyMeta.addJoinColumnMeta(meta); + } else { + JoinColumns joinColumns = field.getAnnotation(JoinColumns.class); + if (joinColumns != null) { + JoinColumn[] array = joinColumns.value(); + for (int i = 0; i < array.length; i++) { + JoinColumn jc = array[i]; + JoinColumnMeta meta = new JoinColumnMeta(jc.name(), jc.referencedColumnName()); + if (i > 0 && (meta.getName() == null || meta.getReferencedColumnName() == null)) { + throw new JoinColumnNameAndReferencedColumnNameMandatoryException(entityMeta.getName(), + propertyMeta.getName(), i + 1); + } + propertyMeta.addJoinColumnMeta(meta); + } + } + } + } + + private void doLob(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + propertyMeta.setLob(field.getAnnotation(Lob.class) != null); + } + + private void doManyToOne(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta, ManyToOne manyToOne) + throws RelationshipNotEntityException { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + Validate.notNull(manyToOne); + propertyMeta.setRelationshipType(RelationshipType.MANY_TO_ONE); + Class<?> relationshipClass = field.getType(); + if (relationshipClass.getAnnotation(Entity.class) == null) { + throw new RelationshipNotEntityException(entityMeta.getName(), propertyMeta.getName(), relationshipClass); + } + propertyMeta.setRelationshipClass(relationshipClass); + } + + private void doName(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + propertyMeta.setName(fromFieldNameToPropertyName(field.getName())); + } + + private void doOneToMany(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta, OneToMany oneToMany) + throws OneToManyNotListException, OneToManyNotGenericsException, RelationshipNotEntityException, + BothMappedByAndJoinColumnException, MappedByMandatoryException { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + Validate.notNull(oneToMany); + propertyMeta.setRelationshipType(RelationshipType.ONE_TO_MANY); + if (List.class.isAssignableFrom(field.getType()) == false) { + throw new OneToManyNotListException(entityMeta.getName(), propertyMeta.getName()); + } + Class<?> relationshipClass = ReflectionUtil.getElementTypeOfList(field.getGenericType()); + if (relationshipClass == null) { + throw new OneToManyNotGenericsException(entityMeta.getName(), propertyMeta.getName()); + } + if (relationshipClass.getAnnotation(Entity.class) == null) { + throw new RelationshipNotEntityException(entityMeta.getName(), propertyMeta.getName(), relationshipClass); + } + propertyMeta.setRelationshipClass(relationshipClass); + String mappedBy = oneToMany.mappedBy(); + if (!StringUtils.isEmpty(mappedBy)) { + if (propertyMeta.getJoinColumnMetaList().size() > 0) { + throw new BothMappedByAndJoinColumnException(entityMeta.getName(), propertyMeta.getName()); + } + propertyMeta.setMappedBy(mappedBy); + } else { + throw new MappedByMandatoryException(entityMeta.getName(), propertyMeta.getName()); + } + } + + private void doOneToOne(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta, OneToOne oneToOne) + throws RelationshipNotEntityException, BothMappedByAndJoinColumnException { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + Validate.notNull(oneToOne); + propertyMeta.setRelationshipType(RelationshipType.ONE_TO_ONE); + Class<?> relationshipClass = field.getType(); + if (relationshipClass.getAnnotation(Entity.class) == null) { + throw new RelationshipNotEntityException(entityMeta.getName(), propertyMeta.getName(), relationshipClass); + } + propertyMeta.setRelationshipClass(relationshipClass); + String mappedBy = oneToOne.mappedBy(); + if (!StringUtils.isEmpty(mappedBy)) { + if (propertyMeta.getJoinColumnMetaList().size() > 0) { + throw new BothMappedByAndJoinColumnException(entityMeta.getName(), propertyMeta.getName()); + } + propertyMeta.setMappedBy(mappedBy); + } + } + + private void doRelationship(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta, + Object relationshipAnnotation) throws UnsupportedRelationshipException, + JoinColumnNameAndReferencedColumnNameMandatoryException, RelationshipNotEntityException, + BothMappedByAndJoinColumnException, OneToManyNotListException, OneToManyNotGenericsException, + MappedByMandatoryException { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + Validate.notNull(relationshipAnnotation); + doJoinColumn(propertyMeta, field, entityMeta); + if (OneToOne.class.isInstance(relationshipAnnotation)) { + doOneToOne(propertyMeta, field, entityMeta, OneToOne.class.cast(relationshipAnnotation)); + } else if (OneToMany.class.isInstance(relationshipAnnotation)) { + doOneToMany(propertyMeta, field, entityMeta, OneToMany.class.cast(relationshipAnnotation)); + } else if (ManyToOne.class.isInstance(relationshipAnnotation)) { + doManyToOne(propertyMeta, field, entityMeta, ManyToOne.class.cast(relationshipAnnotation)); + } else { + throw new UnsupportedRelationshipException(entityMeta.getName(), propertyMeta.getName()); + } + } + + private boolean doSequenceIdGenerator(PropertyMeta propertyMeta, GeneratedValue generatedValue, + EntityMeta entityMeta) { + Validate.notNull(propertyMeta); + Validate.notNull(generatedValue); + Validate.notNull(entityMeta); + String name = generatedValue.generator(); + SequenceGenerator sequenceGenerator; + if (StringUtils.isEmpty(name)) { + sequenceGenerator = DEFAULT_SEQUENCE_GENERATOR; + } else { + sequenceGenerator = propertyMeta.getField().getAnnotation(SequenceGenerator.class); + if (sequenceGenerator == null || !name.equals(sequenceGenerator.name())) { + sequenceGenerator = entityMeta.getEntityClass().getAnnotation(SequenceGenerator.class); + if (sequenceGenerator == null || !name.equals(sequenceGenerator.name())) { + return false; + } + } + } + propertyMeta.setSequenceIdGenerator(new SequenceIdGeneratorMeta(entityMeta, propertyMeta, sequenceGenerator)); + return true; + } + + private boolean doTableIdGenerator(PropertyMeta propertyMeta, GeneratedValue generatedValue, EntityMeta entityMeta) { + Validate.notNull(propertyMeta); + Validate.notNull(generatedValue); + Validate.notNull(entityMeta); + String name = generatedValue.generator(); + TableGenerator tableGenerator; + if (StringUtils.isEmpty(name)) { + tableGenerator = DEFAULT_TABLE_GENERATOR; + } else { + tableGenerator = propertyMeta.getField().getAnnotation(TableGenerator.class); + if (tableGenerator == null || !name.equals(tableGenerator.name())) { + tableGenerator = entityMeta.getEntityClass().getAnnotation(TableGenerator.class); + if (tableGenerator == null || !name.equals(tableGenerator.name())) { + return false; + } + } + } + propertyMeta.setTableIdGenerator(new TableIdGeneratorMeta(entityMeta, propertyMeta, tableGenerator)); + return true; + } + + private void doTemporal(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) + throws TemporalTypeNotSpecifiedException { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + if (propertyMeta.getPropertyClass() != java.util.Date.class + && propertyMeta.getPropertyClass() != Calendar.class) { + return; + } + Temporal temporal = field.getAnnotation(Temporal.class); + if (temporal == null) { + throw new TemporalTypeNotSpecifiedException(entityMeta.getName(), propertyMeta.getName()); + } + propertyMeta.setTemporalType(temporal.value()); + } + + private void doTransient(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + propertyMeta.setTransient(field.getAnnotation(Transient.class) != null || ModifierUtil.isTransient(field)); + } + + private void doVersion(PropertyMeta propertyMeta, Field field, EntityMeta entityMeta) + throws VersionPropertyNotNumberException { + Validate.notNull(propertyMeta); + Validate.notNull(field); + Validate.notNull(entityMeta); + if (field.getAnnotation(Version.class) == null) { + return; + } + Class<?> clazz = ClassUtil.getWrapperClassIfPrimitive(field.getType()); + if (clazz != Integer.class && clazz != Long.class && clazz != int.class && clazz != long.class) { + throw new VersionPropertyNotNumberException(entityMeta.getName(), propertyMeta.getName()); + } + propertyMeta.setVersion(true); + } + + private String fromFieldNameToPropertyName(String name) { + Validate.notNull(name); + return name; + } + + /** + * フィールドに関連のアノテーションが指定されていればそれを取得する。 + * + * @param field フィールド + * @return 関連のアノテーションまたは<code>null</code> + */ + protected Object getRelationshipAnnotation(Field field) { + Validate.notNull(field); + final OneToOne oneToOne = field.getAnnotation(OneToOne.class); + if (oneToOne != null) { + return oneToOne; + } + final OneToMany oneToMany = field.getAnnotation(OneToMany.class); + if (oneToMany != null) { + return oneToMany; + } + final ManyToOne manyToOne = field.getAnnotation(ManyToOne.class); + if (manyToOne != null) { + return manyToOne; + } + final ManyToMany manyToMany = field.getAnnotation(ManyToMany.class); + if (manyToMany != null) { + return manyToMany; + } + return null; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/PropertyMetaFactoryImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/TableMetaFactoryImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/TableMetaFactoryImpl.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/TableMetaFactoryImpl.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,67 +1,67 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 5, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.impl; - -import javax.persistence.Table; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.Validate; - -import org.jiemamy.entity.io.meta.EntityMeta; -import org.jiemamy.entity.io.meta.TableMeta; -import org.jiemamy.entity.io.meta.TableMetaFactory; -import org.jiemamy.utils.JmStringUtil; - -/** - * {@link TableMetaFactory}の実装クラス。 - * - * @author j5ik2o - */ -public class TableMetaFactoryImpl implements TableMetaFactory { - - public TableMeta createTableMeta(EntityMeta entityMeta) { - Validate.notNull(entityMeta); - TableMeta tableMeta = new TableMeta(); - String defaultName = fromEntityNameToTableName(entityMeta.getName()); - Table table = entityMeta.getEntityClass().getAnnotation(Table.class); - if (table != null) { - String name = table.name(); - if (StringUtils.isEmpty(name)) { - name = defaultName; - } - tableMeta.setName(name); - String catalog = table.catalog(); - if (StringUtils.isEmpty(catalog) == false) { - tableMeta.setCatalog(catalog); - } - String schema = table.schema(); - if (StringUtils.isEmpty(schema) == false) { - tableMeta.setSchema(schema); - } - } else { - tableMeta.setName(defaultName); - } - return tableMeta; - } - - private String fromEntityNameToTableName(String entityName) { - Validate.notNull(entityName); - return JmStringUtil.toSQLName(entityName); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 5, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.impl; + +import javax.persistence.Table; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.Validate; + +import org.jiemamy.entity.io.meta.EntityMeta; +import org.jiemamy.entity.io.meta.TableMeta; +import org.jiemamy.entity.io.meta.TableMetaFactory; +import org.jiemamy.utils.JmStringUtil; + +/** + * {@link TableMetaFactory}の実装クラス。 + * + * @author j5ik2o + */ +public class TableMetaFactoryImpl implements TableMetaFactory { + + public TableMeta createTableMeta(EntityMeta entityMeta) { + Validate.notNull(entityMeta); + TableMeta tableMeta = new TableMeta(); + String defaultName = fromEntityNameToTableName(entityMeta.getName()); + Table table = entityMeta.getEntityClass().getAnnotation(Table.class); + if (table != null) { + String name = table.name(); + if (StringUtils.isEmpty(name)) { + name = defaultName; + } + tableMeta.setName(name); + String catalog = table.catalog(); + if (StringUtils.isEmpty(catalog) == false) { + tableMeta.setCatalog(catalog); + } + String schema = table.schema(); + if (StringUtils.isEmpty(schema) == false) { + tableMeta.setSchema(schema); + } + } else { + tableMeta.setName(defaultName); + } + return tableMeta; + } + + private String fromEntityNameToTableName(String entityName) { + Validate.notNull(entityName); + return JmStringUtil.toSQLName(entityName); + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/TableMetaFactoryImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/AnnotationUtil.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/AnnotationUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/AnnotationUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,119 +1,119 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.utils; - -import javax.persistence.Column; -import javax.persistence.SequenceGenerator; -import javax.persistence.Table; -import javax.persistence.TableGenerator; - -import org.jiemamy.utils.ReflectionUtil; - -/** - * アノテーションに関するユーティリティクラスです。 - * - * @author j5ik2o - */ -public class AnnotationUtil { - - /** デフォルトの{@link Table}を取得するためのクラス */ - @Table - protected static class TableAnnotated { - } - - - /** デフォルトの{@link Table} */ - protected static final Table DEFAULT_TABLE = TableAnnotated.class.getAnnotation(Table.class); - - /** デフォルトの{@link Column} */ - @Column(length = 255, precision = 19, scale = 2) - protected static final Column DEFAULT_COLUMN = - ReflectionUtil.getDeclaredFieldNoException(AnnotationUtil.class, "DEFAULT_COLUMN").getAnnotation( - Column.class); - - /** デフォルトの{@link SequenceGenerator} */ - @SequenceGenerator(name = "default") - protected static final SequenceGenerator DEFAULT_SEQUENCE_GENERATOR = - ReflectionUtil.getDeclaredFieldNoException(AnnotationUtil.class, "DEFAULT_SEQUENCE_GENERATOR") - .getAnnotation(SequenceGenerator.class); - - /** デフォルトの{@link TableGenerator} */ - @TableGenerator(name = "default") - protected static final TableGenerator DEFAULT_TABLE_GENERATOR = - ReflectionUtil.getDeclaredFieldNoException(AnnotationUtil.class, "DEFAULT_TABLE_GENERATOR").getAnnotation( - TableGenerator.class); - - /** デフォルトの{@link ReferentialConstraint} */ - @ReferentialConstraint - protected static final ReferentialConstraint DEFAULT_REFERENTIAL_CONSTRAINT = - ReflectionUtil.getDeclaredFieldNoException(AnnotationUtil.class, "DEFAULT_REFERENTIAL_CONSTRAINT") - .getAnnotation(ReferentialConstraint.class); - - - /** - * デフォルトの{@link Column}を取得する。 - * - * @return デフォルトの{@link Column} - */ - public static Column getDefaultColumn() { - return DEFAULT_COLUMN; - } - - /** - * デフォルトの{@link ReferentialConstraint}を取得する。 - * - * @return デフォルトの{@link ReferentialConstraint} - */ - public static ReferentialConstraint getDefaultReferentialConstraint() { - return DEFAULT_REFERENTIAL_CONSTRAINT; - } - - /** - * デフォルトの{@link SequenceGenerator}を取得する。 - * - * @return デフォルトの{@link SequenceGenerator} - */ - public static SequenceGenerator getDefaultSequenceGenerator() { - return DEFAULT_SEQUENCE_GENERATOR; - } - - /** - * デフォルトの{@link Table}を取得する。 - * - * @return デフォルトの{@link Table} - */ - public static Table getDefaultTable() { - return DEFAULT_TABLE; - } - - /** - * デフォルトの{@link TableGenerator}を取得する。 - * - * @return デフォルトの{@link TableGenerator} - */ - public static TableGenerator getDefaultTableGenerator() { - return DEFAULT_TABLE_GENERATOR; - } - - /** - * - */ - protected AnnotationUtil() { - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.utils; + +import javax.persistence.Column; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.TableGenerator; + +import org.jiemamy.utils.ReflectionUtil; + +/** + * アノテーションに関するユーティリティクラスです。 + * + * @author j5ik2o + */ +public class AnnotationUtil { + + /** デフォルトの{@link Table}を取得するためのクラス */ + @Table + protected static class TableAnnotated { + } + + + /** デフォルトの{@link Table} */ + protected static final Table DEFAULT_TABLE = TableAnnotated.class.getAnnotation(Table.class); + + /** デフォルトの{@link Column} */ + @Column(length = 255, precision = 19, scale = 2) + protected static final Column DEFAULT_COLUMN = + ReflectionUtil.getDeclaredFieldNoException(AnnotationUtil.class, "DEFAULT_COLUMN").getAnnotation( + Column.class); + + /** デフォルトの{@link SequenceGenerator} */ + @SequenceGenerator(name = "default") + protected static final SequenceGenerator DEFAULT_SEQUENCE_GENERATOR = + ReflectionUtil.getDeclaredFieldNoException(AnnotationUtil.class, "DEFAULT_SEQUENCE_GENERATOR") + .getAnnotation(SequenceGenerator.class); + + /** デフォルトの{@link TableGenerator} */ + @TableGenerator(name = "default") + protected static final TableGenerator DEFAULT_TABLE_GENERATOR = + ReflectionUtil.getDeclaredFieldNoException(AnnotationUtil.class, "DEFAULT_TABLE_GENERATOR").getAnnotation( + TableGenerator.class); + + /** デフォルトの{@link ReferentialConstraint} */ + @ReferentialConstraint + protected static final ReferentialConstraint DEFAULT_REFERENTIAL_CONSTRAINT = + ReflectionUtil.getDeclaredFieldNoException(AnnotationUtil.class, "DEFAULT_REFERENTIAL_CONSTRAINT") + .getAnnotation(ReferentialConstraint.class); + + + /** + * デフォルトの{@link Column}を取得する。 + * + * @return デフォルトの{@link Column} + */ + public static Column getDefaultColumn() { + return DEFAULT_COLUMN; + } + + /** + * デフォルトの{@link ReferentialConstraint}を取得する。 + * + * @return デフォルトの{@link ReferentialConstraint} + */ + public static ReferentialConstraint getDefaultReferentialConstraint() { + return DEFAULT_REFERENTIAL_CONSTRAINT; + } + + /** + * デフォルトの{@link SequenceGenerator}を取得する。 + * + * @return デフォルトの{@link SequenceGenerator} + */ + public static SequenceGenerator getDefaultSequenceGenerator() { + return DEFAULT_SEQUENCE_GENERATOR; + } + + /** + * デフォルトの{@link Table}を取得する。 + * + * @return デフォルトの{@link Table} + */ + public static Table getDefaultTable() { + return DEFAULT_TABLE; + } + + /** + * デフォルトの{@link TableGenerator}を取得する。 + * + * @return デフォルトの{@link TableGenerator} + */ + public static TableGenerator getDefaultTableGenerator() { + return DEFAULT_TABLE_GENERATOR; + } + + /** + * + */ + protected AnnotationUtil() { + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/AnnotationUtil.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/CaseInsensitiveMap.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/CaseInsensitiveMap.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/CaseInsensitiveMap.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,94 +1,94 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.utils; - -import java.util.Map; - -import org.jiemamy.utils.ArrayMap; - -/** - * キーで大文字小文字を気にしない {@link ArrayMap}です。 - * - * @author j5ik2o - * - */ -public class CaseInsensitiveMap<K, V> extends ArrayMap<K, V> { - - private static final long serialVersionUID = 1L; - - - private static String convertKey(String key) { - return key.toLowerCase(); - } - - /** - * {@link CaseInsensitiveMap}を作成する。 - */ - public CaseInsensitiveMap() { - super(); - } - - /** - * {@link CaseInsensitiveMap}を作成する。 - * - * @param capacity - */ - public CaseInsensitiveMap(int capacity) { - super(capacity); - } - - @Override - public boolean containsKey(Object key) { - return super.containsKey(convertKey(key.toString())); - } - - /** - * キーが含まれているかどうかを取得する。 - * - * @param key - * @return キーが含まれているかどうか - */ - public final boolean containsKey(String key) { - return super.containsKey(convertKey(key)); - } - - @Override - public V get(Object key) { - return super.get(convertKey(key.toString())); - } - - @Override - public V put(Object key, Object value) { - return super.put((K) convertKey(key.toString()), (V) value); - } - - @Override - public final void putAll(Map map) { - for (Object element : map.entrySet()) { - Map.Entry entry = (Map.Entry) element; - put(convertKey(entry.getKey().toString()), entry.getValue()); - } - } - - @Override - public final V remove(Object key) { - return super.remove(convertKey(key.toString())); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.utils; + +import java.util.Map; + +import org.jiemamy.utils.ArrayMap; + +/** + * キーで大文字小文字を気にしない {@link ArrayMap}です。 + * + * @author j5ik2o + * + */ +public class CaseInsensitiveMap<K, V> extends ArrayMap<K, V> { + + private static final long serialVersionUID = 1L; + + + private static String convertKey(String key) { + return key.toLowerCase(); + } + + /** + * {@link CaseInsensitiveMap}を作成する。 + */ + public CaseInsensitiveMap() { + super(); + } + + /** + * {@link CaseInsensitiveMap}を作成する。 + * + * @param capacity + */ + public CaseInsensitiveMap(int capacity) { + super(capacity); + } + + @Override + public boolean containsKey(Object key) { + return super.containsKey(convertKey(key.toString())); + } + + /** + * キーが含まれているかどうかを取得する。 + * + * @param key + * @return キーが含まれているかどうか + */ + public final boolean containsKey(String key) { + return super.containsKey(convertKey(key)); + } + + @Override + public V get(Object key) { + return super.get(convertKey(key.toString())); + } + + @Override + public V put(Object key, Object value) { + return super.put((K) convertKey(key.toString()), (V) value); + } + + @Override + public final void putAll(Map map) { + for (Object element : map.entrySet()) { + Map.Entry entry = (Map.Entry) element; + put(convertKey(entry.getKey().toString()), entry.getValue()); + } + } + + @Override + public final V remove(Object key) { + return super.remove(convertKey(key.toString())); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/CaseInsensitiveMap.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/CaseInsensitiveSet.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/CaseInsensitiveSet.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/CaseInsensitiveSet.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,104 +1,104 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.utils; - -import java.io.Serializable; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * 大文字小文字を気にしない {@link Set}。 - * - * @author j5ik2o - * - */ - @ SuppressWarnings("unchecked") -public class CaseInsensitiveSet extends AbstractSet implements Set, Serializable { - - static final long serialVersionUID = 0L; - - private transient Map map; - - private static final Object PRESENT = new Object(); - - - /** - * {@link CaseInsensitiveSet}を作成する。 - */ - public CaseInsensitiveSet() { - map = new CaseInsensitiveMap(); - } - - /** - * {@link CaseInsensitiveSet}を作成する。 - * - * @param c - */ - public CaseInsensitiveSet(Collection c) { - map = new CaseInsensitiveMap(Math.max((int) (c.size() / .75f) + 1, 16)); - addAll(c); - } - - /** - * {@link CaseInsensitiveSet}を作成する。 - * - * @param initialCapacity - */ - public CaseInsensitiveSet(int initialCapacity) { - map = new CaseInsensitiveMap(initialCapacity); - } - - @Override - public boolean add(Object o) { - return map.put(o, PRESENT) == null; - } - - @Override - public void clear() { - map.clear(); - } - - @Override - public boolean contains(Object o) { - return map.containsKey(o); - } - - @Override - public boolean isEmpty() { - return map.isEmpty(); - } - - @Override - public Iterator iterator() { - return map.keySet().iterator(); - } - - @Override - public boolean remove(Object o) { - return map.remove(o) == PRESENT; - } - - @Override - public int size() { - return map.size(); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.utils; + +import java.io.Serializable; +import java.util.AbstractSet; +import java.util.Collection; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +/** + * 大文字小文字を気にしない {@link Set}。 + * + * @author j5ik2o + * + */ + @ SuppressWarnings("unchecked") +public class CaseInsensitiveSet extends AbstractSet implements Set, Serializable { + + static final long serialVersionUID = 0L; + + private transient Map map; + + private static final Object PRESENT = new Object(); + + + /** + * {@link CaseInsensitiveSet}を作成する。 + */ + public CaseInsensitiveSet() { + map = new CaseInsensitiveMap(); + } + + /** + * {@link CaseInsensitiveSet}を作成する。 + * + * @param c + */ + public CaseInsensitiveSet(Collection c) { + map = new CaseInsensitiveMap(Math.max((int) (c.size() / .75f) + 1, 16)); + addAll(c); + } + + /** + * {@link CaseInsensitiveSet}を作成する。 + * + * @param initialCapacity + */ + public CaseInsensitiveSet(int initialCapacity) { + map = new CaseInsensitiveMap(initialCapacity); + } + + @Override + public boolean add(Object o) { + return map.put(o, PRESENT) == null; + } + + @Override + public void clear() { + map.clear(); + } + + @Override + public boolean contains(Object o) { + return map.containsKey(o); + } + + @Override + public boolean isEmpty() { + return map.isEmpty(); + } + + @Override + public Iterator iterator() { + return map.keySet().iterator(); + } + + @Override + public boolean remove(Object o) { + return map.remove(o) == PRESENT; + } + + @Override + public int size() { + return map.size(); + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/CaseInsensitiveSet.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ColumnUtil.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ColumnUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ColumnUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,82 +1,82 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.utils; - -/** - * カラムに関するユーティリティクラス。 - * - * @author j5ik2o - */ -public class ColumnUtil { - - /** - * カラムのデータ型をフォーマットする。 - * <p> - * カラムのデータ型に含まれる置換文字を置き換える。 - * <ul> - * <li>$l を長さで置き換える。</li> - * <li>$p を精度で置き換える。</li> - * <li>$s をスケールで置き換える。</li> - * </ul> - * </p> - * - * @param dataType カラムのデータ型 - * @param length 長さ - * @param precision 精度 - * @param scale スケール - * @return フォーマットされたカラムのデータ型 - */ - public static String formatDataType(String dataType, int length, int precision, int scale) { - StringBuilder buf = new StringBuilder(); - for (int i = 0; i < dataType.length(); i++) { - char c = dataType.charAt(i); - if (c == '$') { - i++; - if (i < dataType.length()) { - c = dataType.charAt(i); - switch (c) { - case 'l': - buf.append(length); - break; - case 'p': - buf.append(precision); - break; - case 's': - buf.append(scale); - break; - default: - buf.append('$'); - buf.append(c); - break; - } - } else { - buf.append(c); - } - } else { - buf.append(c); - } - } - return buf.toString(); - } - - /** - * - */ - protected ColumnUtil() { - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.utils; + +/** + * カラムに関するユーティリティクラス。 + * + * @author j5ik2o + */ +public class ColumnUtil { + + /** + * カラムのデータ型をフォーマットする。 + * <p> + * カラムのデータ型に含まれる置換文字を置き換える。 + * <ul> + * <li>$l を長さで置き換える。</li> + * <li>$p を精度で置き換える。</li> + * <li>$s をスケールで置き換える。</li> + * </ul> + * </p> + * + * @param dataType カラムのデータ型 + * @param length 長さ + * @param precision 精度 + * @param scale スケール + * @return フォーマットされたカラムのデータ型 + */ + public static String formatDataType(String dataType, int length, int precision, int scale) { + StringBuilder buf = new StringBuilder(); + for (int i = 0; i < dataType.length(); i++) { + char c = dataType.charAt(i); + if (c == '$') { + i++; + if (i < dataType.length()) { + c = dataType.charAt(i); + switch (c) { + case 'l': + buf.append(length); + break; + case 'p': + buf.append(precision); + break; + case 's': + buf.append(scale); + break; + default: + buf.append('$'); + buf.append(c); + break; + } + } else { + buf.append(c); + } + } else { + buf.append(c); + } + } + return buf.toString(); + } + + /** + * + */ + protected ColumnUtil() { + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ColumnUtil.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/FileUtil.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/FileUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/FileUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,208 +1,208 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.utils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FilenameFilter; -import java.io.IOException; -import java.nio.channels.FileChannel; -import java.util.Arrays; -import java.util.Comparator; - -/** - * {@link File}に関するユーティリティクラス。 - * - * @author j5ik2o - */ -public class FileUtil { - - /** - * ファイルを扱うインタフェースです・ - * - * @author j5ik2o - */ - public interface FileHandler { - - /** - * 処理する。 - * - * @param file {@link File} - */ - void handle(File file); - } - - - /** - * ファイルをコピーし追加する。 - * - * @param src コピー元ファイル - * @param dest コピー先ファイル - * @throws IOException 入出力が失敗した場合 - */ - public static void append(File src, File dest) throws IOException { - FileInputStream in = null; - FileOutputStream out = null; - try { - in = new FileInputStream(src); - out = new FileOutputStream(dest, true); - copyInternal(in, out); - } finally { - if (in != null) { - in.close(); - } - if (out != null) { - out.close(); - } - } - } - - /** - * ファイルをコピーする。 - * - * @param src コピー元ファイル - * @param dest コピー先ファイル - * @throws IOException 入出力が失敗した場合 - */ - public static void copy(File src, File dest) throws IOException { - FileInputStream in = null; - FileOutputStream out = null; - try { - in = new FileInputStream(src); - out = new FileOutputStream(dest); - copyInternal(in, out); - } finally { - if (in != null) { - in.close(); - } - if (out != null) { - out.close(); - } - } - } - - /** - * 内部的にコピーする。 - * - * @param in コピー元 - * @param out コピー先 - * @throws IOException 入出力が失敗した場合 - */ - protected static void copyInternal(FileInputStream in, FileOutputStream out) throws IOException { - FileChannel src = in.getChannel(); - FileChannel dest = out.getChannel(); - src.transferTo(0, src.size(), dest); - } - - /** - * Javaファイルを作成する。 - * - * @param baseDir ベースディレクトリ - * @param packageName パッケージ名 - * @param shortClassName クラスの単純名 - * @return Javaファイル - */ - public static File createJavaFile(File baseDir, String packageName, String shortClassName) { - File packageDir; - if (packageName == null) { - packageDir = baseDir; - } else { - packageDir = new File(baseDir, packageName.replace('.', File.separatorChar)); - } - return new File(packageDir, shortClassName + ".java"); - } - - /** - * 新しいファイルを不可分 (atomic) に生成する。 - * - * @param file ファイル - * @return 指定されたファイルが存在せず、ファイルの生成に成功した場合は{@code true}、示されたファイルがすでに存在する場合は - * {@code false} - * @throws IOException 入出力が失敗した場合 - */ - public static boolean createNewFile(File file) throws IOException { - return file.createNewFile(); - } - - /** - * 一時ファイルを作成する。 - * - * @param prefix 接頭辞文字列。3 文字以上の長さが必要である - * @param suffix 接尾辞文字列。null も指定でき、その場合は、接尾辞 ".tmp" が使用される - * @return {@link File} - * @throws IOException 入出力が失敗した場合 - */ - public static File createTempFile(String prefix, String suffix) throws IOException { - return File.createTempFile(prefix, suffix); - } - - /** - * ファイルの正規の形式を取得する。 - * - * @param file ファイル - * @return 正規の形式 - * @throws IOException 入出力が失敗した場合 - */ - public static File getCanonicalFile(File file) throws IOException { - return file.getCanonicalFile(); - } - - /** - * ファイルの正規のパス名文字列を取得する。 - * - * @param file ファイル - * @return ファイルの正規パス名文字列 - * @throws IOException 入出力が失敗した場合 - */ - public static String getCanonicalPath(File file) throws IOException { - return file.getCanonicalPath(); - } - - /** - * ディレクトリを横断する。 - * - * @param dir ディレクトリ - * @param filter フィルタ - * @param comparator コンパレータ - * @param handler ハンドラ - */ - public static void traverseDirectory(File dir, FilenameFilter filter, Comparator<File> comparator, - FileHandler handler) { - if (!dir.exists()) { - return; - } - File[] files = dir.listFiles(filter); - if (files == null) { - return; - } - Arrays.sort(files, comparator); - for (File file : files) { - if (file.isDirectory()) { - traverseDirectory(file, filter, comparator, handler); - } - handler.handle(file); - } - } - - /** - * - */ - protected FileUtil() { - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.utils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FilenameFilter; +import java.io.IOException; +import java.nio.channels.FileChannel; +import java.util.Arrays; +import java.util.Comparator; + +/** + * {@link File}に関するユーティリティクラス。 + * + * @author j5ik2o + */ +public class FileUtil { + + /** + * ファイルを扱うインタフェースです・ + * + * @author j5ik2o + */ + public interface FileHandler { + + /** + * 処理する。 + * + * @param file {@link File} + */ + void handle(File file); + } + + + /** + * ファイルをコピーし追加する。 + * + * @param src コピー元ファイル + * @param dest コピー先ファイル + * @throws IOException 入出力が失敗した場合 + */ + public static void append(File src, File dest) throws IOException { + FileInputStream in = null; + FileOutputStream out = null; + try { + in = new FileInputStream(src); + out = new FileOutputStream(dest, true); + copyInternal(in, out); + } finally { + if (in != null) { + in.close(); + } + if (out != null) { + out.close(); + } + } + } + + /** + * ファイルをコピーする。 + * + * @param src コピー元ファイル + * @param dest コピー先ファイル + * @throws IOException 入出力が失敗した場合 + */ + public static void copy(File src, File dest) throws IOException { + FileInputStream in = null; + FileOutputStream out = null; + try { + in = new FileInputStream(src); + out = new FileOutputStream(dest); + copyInternal(in, out); + } finally { + if (in != null) { + in.close(); + } + if (out != null) { + out.close(); + } + } + } + + /** + * 内部的にコピーする。 + * + * @param in コピー元 + * @param out コピー先 + * @throws IOException 入出力が失敗した場合 + */ + protected static void copyInternal(FileInputStream in, FileOutputStream out) throws IOException { + FileChannel src = in.getChannel(); + FileChannel dest = out.getChannel(); + src.transferTo(0, src.size(), dest); + } + + /** + * Javaファイルを作成する。 + * + * @param baseDir ベースディレクトリ + * @param packageName パッケージ名 + * @param shortClassName クラスの単純名 + * @return Javaファイル + */ + public static File createJavaFile(File baseDir, String packageName, String shortClassName) { + File packageDir; + if (packageName == null) { + packageDir = baseDir; + } else { + packageDir = new File(baseDir, packageName.replace('.', File.separatorChar)); + } + return new File(packageDir, shortClassName + ".java"); + } + + /** + * 新しいファイルを不可分 (atomic) に生成する。 + * + * @param file ファイル + * @return 指定されたファイルが存在せず、ファイルの生成に成功した場合は{@code true}、示されたファイルがすでに存在する場合は + * {@code false} + * @throws IOException 入出力が失敗した場合 + */ + public static boolean createNewFile(File file) throws IOException { + return file.createNewFile(); + } + + /** + * 一時ファイルを作成する。 + * + * @param prefix 接頭辞文字列。3 文字以上の長さが必要である + * @param suffix 接尾辞文字列。null も指定でき、その場合は、接尾辞 ".tmp" が使用される + * @return {@link File} + * @throws IOException 入出力が失敗した場合 + */ + public static File createTempFile(String prefix, String suffix) throws IOException { + return File.createTempFile(prefix, suffix); + } + + /** + * ファイルの正規の形式を取得する。 + * + * @param file ファイル + * @return 正規の形式 + * @throws IOException 入出力が失敗した場合 + */ + public static File getCanonicalFile(File file) throws IOException { + return file.getCanonicalFile(); + } + + /** + * ファイルの正規のパス名文字列を取得する。 + * + * @param file ファイル + * @return ファイルの正規パス名文字列 + * @throws IOException 入出力が失敗した場合 + */ + public static String getCanonicalPath(File file) throws IOException { + return file.getCanonicalPath(); + } + + /** + * ディレクトリを横断する。 + * + * @param dir ディレクトリ + * @param filter フィルタ + * @param comparator コンパレータ + * @param handler ハンドラ + */ + public static void traverseDirectory(File dir, FilenameFilter filter, Comparator<File> comparator, + FileHandler handler) { + if (!dir.exists()) { + return; + } + File[] files = dir.listFiles(filter); + if (files == null) { + return; + } + Arrays.sort(files, comparator); + for (File file : files) { + if (file.isDirectory()) { + traverseDirectory(file, filter, comparator, handler); + } + handler.handle(file); + } + } + + /** + * + */ + protected FileUtil() { + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/FileUtil.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ReferentialActionType.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ReferentialActionType.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ReferentialActionType.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,41 +1,41 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.utils; - -/** - * 参照動作の列挙型。 - * - * @author j5ik2o - */ -public enum ReferentialActionType { - /** 波及 */ - CASCADE, - - /** NULL値の設定 */ - SET_NULL, - - /** デフォルト値の設定 */ - SET_DEFAULT, - - /** 制限 */ - RESTRICT, - - /** 動作なし */ - NO_ACTION -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.utils; + +/** + * 参照動作の列挙型。 + * + * @author j5ik2o + */ +public enum ReferentialActionType { + /** 波及 */ + CASCADE, + + /** NULL値の設定 */ + SET_NULL, + + /** デフォルト値の設定 */ + SET_DEFAULT, + + /** 制限 */ + RESTRICT, + + /** 動作なし */ + NO_ACTION +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ReferentialActionType.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ReferentialConstraint.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ReferentialConstraint.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ReferentialConstraint.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,48 +1,48 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 7, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.utils; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 参照整合性制約。 - * <p> - * S2JDBC-Genなど、スキーマ生成のツールにより参照されるアノテーションです。 S2JDBCの実行時には利用されません。 - * </p> - * - * @author j5ik2o - */ - @ Retention(RetentionPolicy.RUNTIME) - @ Target( { - ElementType.FIELD -}) -public @interface ReferentialConstraint { - - /** 制約を有効にする場合{@code true}、しない場合{@code false} */ - boolean enable() default true; - - /** 削除規則 */ - ReferentialActionType onDelete() default ReferentialActionType.NO_ACTION; - - /** 更新規則 */ - ReferentialActionType onUpdate() default ReferentialActionType.NO_ACTION; -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.utils; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 参照整合性制約。 + * <p> + * S2JDBC-Genなど、スキーマ生成のツールにより参照されるアノテーションです。 S2JDBCの実行時には利用されません。 + * </p> + * + * @author j5ik2o + */ + @ Retention(RetentionPolicy.RUNTIME) + @ Target( { + ElementType.FIELD +}) +public @interface ReferentialConstraint { + + /** 制約を有効にする場合{@code true}、しない場合{@code false} */ + boolean enable() default true; + + /** 削除規則 */ + ReferentialActionType onDelete() default ReferentialActionType.NO_ACTION; + + /** 更新規則 */ + ReferentialActionType onUpdate() default ReferentialActionType.NO_ACTION; +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/utils/ReferentialConstraint.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/test/java/example/entity/Depertment.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/test/java/example/entity/Depertment.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/test/java/example/entity/Depertment.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,106 +1,106 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 8, 2009 - * - * This file is part of Jiemamy. - * - * 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 example.entity; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Version; - -import org.jiemamy.entity.io.annotation.ColumnName; -import org.jiemamy.entity.io.annotation.TableName; - -/** - * 部署テーブル。 - * - * @author j5ik2o - */ - @ Entity - @ TableName(logical = "部署") -public class Depertment { - - @Id - @ColumnName(logical = "部署ID") - private Long depertmentId; - - @Column(nullable = false) - @ColumnName(logical = "部署名") - private String depertmentName; - - @Version - @Column(nullable = false) - @ColumnName(logical = "バージョン") - private Long version; - - - /** - * 部署IDを取得する。 - * - * @return 部署ID - */ - public Long getDepertmentId() { - return depertmentId; - } - - /** - * 部署名を取得する。 - * - * @return 部署名 - */ - public String getDepertmentName() { - return depertmentName; - } - - /** - * バージョンを取得する。 - * - * @return バージョン - */ - public Long getVersion() { - return version; - } - - /** - * 部署IDを設定する。 - * - * @param depertmentId 部署ID - */ - public void setDepertmentId(Long depertmentId) { - this.depertmentId = depertmentId; - } - - /** - * 部署名を設定する。 - * - * @param depertmentName 部署名 - */ - public void setDepertmentName(String depertmentName) { - this.depertmentName = depertmentName; - } - - /** - * バージョンを設定する。 - * - * @param version バージョン - */ - public void setVersion(Long version) { - this.version = version; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 8, 2009 + * + * This file is part of Jiemamy. + * + * 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 example.entity; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Version; + +import org.jiemamy.entity.io.annotation.ColumnName; +import org.jiemamy.entity.io.annotation.TableName; + +/** + * 部署テーブル。 + * + * @author j5ik2o + */ + @ Entity + @ TableName(logical = "部署") +public class Depertment { + + @Id + @ColumnName(logical = "部署ID") + private Long depertmentId; + + @Column(nullable = false) + @ColumnName(logical = "部署名") + private String depertmentName; + + @Version + @Column(nullable = false) + @ColumnName(logical = "バージョン") + private Long version; + + + /** + * 部署IDを取得する。 + * + * @return 部署ID + */ + public Long getDepertmentId() { + return depertmentId; + } + + /** + * 部署名を取得する。 + * + * @return 部署名 + */ + public String getDepertmentName() { + return depertmentName; + } + + /** + * バージョンを取得する。 + * + * @return バージョン + */ + public Long getVersion() { + return version; + } + + /** + * 部署IDを設定する。 + * + * @param depertmentId 部署ID + */ + public void setDepertmentId(Long depertmentId) { + this.depertmentId = depertmentId; + } + + /** + * 部署名を設定する。 + * + * @param depertmentName 部署名 + */ + public void setDepertmentName(String depertmentName) { + this.depertmentName = depertmentName; + } + + /** + * バージョンを設定する。 + * + * @param version バージョン + */ + public void setVersion(Long version) { + this.version = version; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/test/java/example/entity/Depertment.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/test/java/example/entity/Employee.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/test/java/example/entity/Employee.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/test/java/example/entity/Employee.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,153 +1,153 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 2, 2009 - * - * This file is part of Jiemamy. - * - * 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 example.entity; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.persistence.Version; - -import org.jiemamy.entity.io.annotation.ColumnName; -import org.jiemamy.entity.io.annotation.TableName; - -/** - * 従業員 - * - * @author j5ik2o - */ - @ Entity - @ Table(name = "EMPLOYEE") - @ TableName(logical = "従業員") -public class Employee { - - @Id - @ColumnName(logical = "従業員ID") - private Long employeeId; - - @Column(nullable = false) - @ColumnName(logical = "従業員名") - private String employeeName; - - @Column(nullable = false) - @ColumnName(logical = "部署ID") - private Long depertmentId; - - @Version - @Column(nullable = false) - @ColumnName(logical = "バージョン") - private Long version; - - @ManyToOne - @JoinColumn(name = "DEPERTMENT_ID", referencedColumnName = "DEPERTMENT_ID") - private Depertment depertment; - - - /** - * 部署を取得する。 - * - * @return 部署 - */ - public Depertment getDepertment() { - return depertment; - } - - /** - * 部署IDを取得する。 - * - * @return 部署ID - */ - public Long getDepertmentId() { - return depertmentId; - } - - /** - * 従業員IDを取得する。 - * - * @return 従業員ID - */ - public Long getEmployeeId() { - return employeeId; - } - - /** - * 従業員名を取得する。 - * - * @return 従業員名 - */ - public String getEmployeeName() { - return employeeName; - } - - /** - * バージョンを取得する。 - * - * @return バージョン - */ - public Long getVersion() { - return version; - } - - /** - * 部署を設定する。 - * - * @param depertment 部署 - */ - public void setDepertment(Depertment depertment) { - this.depertment = depertment; - } - - /** - * 部署IDを設定する。 - * - * @param depertmentId 部署ID - */ - public void setDepertmentId(Long depertmentId) { - this.depertmentId = depertmentId; - } - - /** - * 従業員IDを設定する。 - * - * @param employeeId 従業員ID - */ - public void setEmployeeId(Long employeeId) { - this.employeeId = employeeId; - } - - /** - * 従業員名を設定する。 - * - * @param employeeName 従業員名 - */ - public void setEmployeeName(String employeeName) { - this.employeeName = employeeName; - } - - /** - * バージョンを設定する。 - * - * @param version バージョン - */ - public void setVersion(Long version) { - this.version = version; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 2, 2009 + * + * This file is part of Jiemamy. + * + * 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 example.entity; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Version; + +import org.jiemamy.entity.io.annotation.ColumnName; +import org.jiemamy.entity.io.annotation.TableName; + +/** + * 従業員 + * + * @author j5ik2o + */ + @ Entity + @ Table(name = "EMPLOYEE") + @ TableName(logical = "従業員") +public class Employee { + + @Id + @ColumnName(logical = "従業員ID") + private Long employeeId; + + @Column(nullable = false) + @ColumnName(logical = "従業員名") + private String employeeName; + + @Column(nullable = false) + @ColumnName(logical = "部署ID") + private Long depertmentId; + + @Version + @Column(nullable = false) + @ColumnName(logical = "バージョン") + private Long version; + + @ManyToOne + @JoinColumn(name = "DEPERTMENT_ID", referencedColumnName = "DEPERTMENT_ID") + private Depertment depertment; + + + /** + * 部署を取得する。 + * + * @return 部署 + */ + public Depertment getDepertment() { + return depertment; + } + + /** + * 部署IDを取得する。 + * + * @return 部署ID + */ + public Long getDepertmentId() { + return depertmentId; + } + + /** + * 従業員IDを取得する。 + * + * @return 従業員ID + */ + public Long getEmployeeId() { + return employeeId; + } + + /** + * 従業員名を取得する。 + * + * @return 従業員名 + */ + public String getEmployeeName() { + return employeeName; + } + + /** + * バージョンを取得する。 + * + * @return バージョン + */ + public Long getVersion() { + return version; + } + + /** + * 部署を設定する。 + * + * @param depertment 部署 + */ + public void setDepertment(Depertment depertment) { + this.depertment = depertment; + } + + /** + * 部署IDを設定する。 + * + * @param depertmentId 部署ID + */ + public void setDepertmentId(Long depertmentId) { + this.depertmentId = depertmentId; + } + + /** + * 従業員IDを設定する。 + * + * @param employeeId 従業員ID + */ + public void setEmployeeId(Long employeeId) { + this.employeeId = employeeId; + } + + /** + * 従業員名を設定する。 + * + * @param employeeName 従業員名 + */ + public void setEmployeeName(String employeeName) { + this.employeeName = employeeName; + } + + /** + * バージョンを設定する。 + * + * @param version バージョン + */ + public void setVersion(Long version) { + this.version = version; + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/test/java/example/entity/Employee.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescSetWriterImplTest.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescSetWriterImplTest.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescSetWriterImplTest.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,148 +1,148 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 14, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.gen.desc.impl; - -import java.io.File; -import java.io.IOException; -import java.sql.Types; -import java.util.List; -import java.util.regex.Pattern; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.jiemamy.Jiemamy; -import org.jiemamy.dialect.generic.GenericDialect; -import org.jiemamy.entity.io.gen.desc.DefaultEntityDescSetWriterContext; -import org.jiemamy.entity.io.gen.desc.DefaultEntityDescSetWriterFactory; -import org.jiemamy.entity.io.gen.desc.EntityDescSetWriter; -import org.jiemamy.entity.io.gen.dialect.StandardGenDialect; -import org.jiemamy.entity.io.gen.meta.DbColumnMeta; -import org.jiemamy.entity.io.gen.meta.DbTableMeta; -import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; -import org.jiemamy.internal.test.ReflectionDialectProvider; -import org.jiemamy.model.RootModel; -import org.jiemamy.utils.ClassUtil; -import org.jiemamy.utils.CollectionsUtil; -import org.jiemamy.utils.ResourceNotFoundException; -import org.jiemamy.utils.ResourceUtil; - -/** - * {@link EntityDescSetWriterImpl}のテスト。 - * - * @author j5ik2o - */ -public class EntityDescSetWriterImplTest { - - private static class DbTableMetaReaderImpl implements DbTableMetaReader { - - List<DbTableMeta> dbTableMetas = CollectionsUtil.newArrayList(); - - - public List<DbTableMeta> read() { - return dbTableMetas; - } - - } - - - private EntityDescSetWriter entityDescSetWriter; - - private static final Logger LOG = LoggerFactory.getLogger(EntityDescSetWriterImplTest.class); - - private Jiemamy jiemamy; - - private RootModel rootModel; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - jiemamy = Jiemamy.newInstance(new ReflectionDialectProvider()); - rootModel = jiemamy.getFactory().getRootModel(); - rootModel.setDialectClassName(GenericDialect.class.getName()); - } - - /** - * Test method for {@link org.jiemamy.entity.io.gen.desc.impl.EntityDescSetWriterImpl#write(java.util.List)}. - * @throws IOException - * @throws IdentityNotSupportedException - * @throws ClassNotFoundException - * @throws ResourceNotFoundException - */ - @Test - @Ignore - public void testWrite() throws IOException, IdentityNotSupportedException, ClassNotFoundException, - ResourceNotFoundException { - DefaultEntityDescSetWriterContext context = new DefaultEntityDescSetWriterContext(); - - //context.setDialect(new TestDialect(jiemamy.getFactory(), jiemamy.getDialect(rootModel))); - DbTableMetaReaderImpl dbTableMetaReader = new DbTableMetaReaderImpl(); - context.setDbTableMetaReader(dbTableMetaReader); - context.setDialect(new StandardGenDialect()); - context.setUseAccessor(true); - context.setOverwrite(true); - context.setJavaSrcFileEncoding("UTF-8"); - context.setRootPackageName("test"); - context.setEntityPackageName("entity"); - context.setTemplateName("entity.ftl"); - context.setTemplateFileEncoding("UTF-8"); - context.setVersionColumnNamePattern(Pattern.compile("VERSION([_]?NO)?")); - String packageName = ClassUtil.getPackageName(getClass()); - File dir = ResourceUtil.getResourceAsFile(packageName.replace('.', '/')); - - context.setJavaSrcFileDestDir(dir); - entityDescSetWriter = new DefaultEntityDescSetWriterFactory().createEntityDescSetWriter(context); - List<DbTableMeta> dbTableMetaList = dbTableMetaReader.dbTableMetas; - DbTableMeta dbTableMeta = new DbTableMeta(); - dbTableMeta.setName("EMPLOYEE"); - - DbColumnMeta columnMeta = new DbColumnMeta(); - columnMeta.setName("EMPLOYEE_ID"); - columnMeta.setNullable(false); - columnMeta.setPrimaryKey(true); - columnMeta.setSqlType(Types.BIGINT); - columnMeta.setTypeName("BIGINT"); - dbTableMeta.addColumnMeta(columnMeta); - - columnMeta = new DbColumnMeta(); - columnMeta.setName("EMPLOYEE_NAME"); - columnMeta.setNullable(false); - columnMeta.setSqlType(Types.VARCHAR); - columnMeta.setTypeName("VARCHAR"); - dbTableMeta.addColumnMeta(columnMeta); - - columnMeta = new DbColumnMeta(); - columnMeta.setName("VERSION_NO"); - columnMeta.setNullable(false); - columnMeta.setSqlType(Types.BIGINT); - columnMeta.setTypeName("BIGINT"); - dbTableMeta.addColumnMeta(columnMeta); - - dbTableMetaList.add(dbTableMeta); - entityDescSetWriter.write(); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 14, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.gen.desc.impl; + +import java.io.File; +import java.io.IOException; +import java.sql.Types; +import java.util.List; +import java.util.regex.Pattern; + +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jiemamy.Jiemamy; +import org.jiemamy.dialect.generic.GenericDialect; +import org.jiemamy.entity.io.gen.desc.DefaultEntityDescSetWriterContext; +import org.jiemamy.entity.io.gen.desc.DefaultEntityDescSetWriterFactory; +import org.jiemamy.entity.io.gen.desc.EntityDescSetWriter; +import org.jiemamy.entity.io.gen.dialect.StandardGenDialect; +import org.jiemamy.entity.io.gen.meta.DbColumnMeta; +import org.jiemamy.entity.io.gen.meta.DbTableMeta; +import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; +import org.jiemamy.internal.test.ReflectionDialectProvider; +import org.jiemamy.model.RootModel; +import org.jiemamy.utils.ClassUtil; +import org.jiemamy.utils.CollectionsUtil; +import org.jiemamy.utils.ResourceNotFoundException; +import org.jiemamy.utils.ResourceUtil; + +/** + * {@link EntityDescSetWriterImpl}のテスト。 + * + * @author j5ik2o + */ +public class EntityDescSetWriterImplTest { + + private static class DbTableMetaReaderImpl implements DbTableMetaReader { + + List<DbTableMeta> dbTableMetas = CollectionsUtil.newArrayList(); + + + public List<DbTableMeta> read() { + return dbTableMetas; + } + + } + + + private EntityDescSetWriter entityDescSetWriter; + + private static final Logger LOG = LoggerFactory.getLogger(EntityDescSetWriterImplTest.class); + + private Jiemamy jiemamy; + + private RootModel rootModel; + + + /** + * テストを初期化する。 + * + * @throws Exception 例外が発生した場合 + */ + @Before + public void setUp() throws Exception { + jiemamy = Jiemamy.newInstance(new ReflectionDialectProvider()); + rootModel = jiemamy.getFactory().getRootModel(); + rootModel.setDialectClassName(GenericDialect.class.getName()); + } + + /** + * Test method for {@link org.jiemamy.entity.io.gen.desc.impl.EntityDescSetWriterImpl#write(java.util.List)}. + * @throws IOException + * @throws IdentityNotSupportedException + * @throws ClassNotFoundException + * @throws ResourceNotFoundException + */ + @Test + @Ignore + public void testWrite() throws IOException, IdentityNotSupportedException, ClassNotFoundException, + ResourceNotFoundException { + DefaultEntityDescSetWriterContext context = new DefaultEntityDescSetWriterContext(); + + //context.setDialect(new TestDialect(jiemamy.getFactory(), jiemamy.getDialect(rootModel))); + DbTableMetaReaderImpl dbTableMetaReader = new DbTableMetaReaderImpl(); + context.setDbTableMetaReader(dbTableMetaReader); + context.setDialect(new StandardGenDialect()); + context.setUseAccessor(true); + context.setOverwrite(true); + context.setJavaSrcFileEncoding("UTF-8"); + context.setRootPackageName("test"); + context.setEntityPackageName("entity"); + context.setTemplateName("entity.ftl"); + context.setTemplateFileEncoding("UTF-8"); + context.setVersionColumnNamePattern(Pattern.compile("VERSION([_]?NO)?")); + String packageName = ClassUtil.getPackageName(getClass()); + File dir = ResourceUtil.getResourceAsFile(packageName.replace('.', '/')); + + context.setJavaSrcFileDestDir(dir); + entityDescSetWriter = new DefaultEntityDescSetWriterFactory().createEntityDescSetWriter(context); + List<DbTableMeta> dbTableMetaList = dbTableMetaReader.dbTableMetas; + DbTableMeta dbTableMeta = new DbTableMeta(); + dbTableMeta.setName("EMPLOYEE"); + + DbColumnMeta columnMeta = new DbColumnMeta(); + columnMeta.setName("EMPLOYEE_ID"); + columnMeta.setNullable(false); + columnMeta.setPrimaryKey(true); + columnMeta.setSqlType(Types.BIGINT); + columnMeta.setTypeName("BIGINT"); + dbTableMeta.addColumnMeta(columnMeta); + + columnMeta = new DbColumnMeta(); + columnMeta.setName("EMPLOYEE_NAME"); + columnMeta.setNullable(false); + columnMeta.setSqlType(Types.VARCHAR); + columnMeta.setTypeName("VARCHAR"); + dbTableMeta.addColumnMeta(columnMeta); + + columnMeta = new DbColumnMeta(); + columnMeta.setName("VERSION_NO"); + columnMeta.setNullable(false); + columnMeta.setSqlType(Types.BIGINT); + columnMeta.setTypeName("BIGINT"); + dbTableMeta.addColumnMeta(columnMeta); + + dbTableMetaList.add(dbTableMeta); + entityDescSetWriter.write(); + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescSetWriterImplTest.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/EntityMetaReaderImplTest.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/EntityMetaReaderImplTest.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/EntityMetaReaderImplTest.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,193 +1,193 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.impl; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -import java.io.File; -import java.util.List; - -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.jiemamy.entity.io.meta.DefaultEntityMetaReaderContext; -import org.jiemamy.entity.io.meta.DefaultEntityMetaReaderFactory; -import org.jiemamy.entity.io.meta.EntityMeta; -import org.jiemamy.entity.io.meta.EntityMetaReader; -import org.jiemamy.entity.io.meta.RelationshipType; -import org.jiemamy.utils.CollectionsUtil; -import org.jiemamy.utils.ResourceUtil; - -/** - * TODO for kato - * - * @author kato - */ -public class EntityMetaReaderImplTest { - - private EntityMetaReader entityMetaReader; - - private static final Logger LOG = LoggerFactory.getLogger(EntityMetaReaderImplTest.class); - - - /** - * Test method for {@link org.jiemamy.entity.io.meta.impl.EntityMetaReaderImpl#read()}. - * @throws Exception 例外 - */ - @Test - public void testRead() throws Exception { - DefaultEntityMetaReaderContext context = new DefaultEntityMetaReaderContext(); - context.setJavaFileEncoding("UTF-8"); - List<File> classPathDirs = CollectionsUtil.newArrayList(); - classPathDirs.add(ResourceUtil.getBuildDirNoException(example.entity.Employee.class).getCanonicalFile()); - context.setClassPathDirs(classPathDirs); - context.setPackageName("example.entity"); - context.setReadComment(true); - List<File> javaFileSrcDirs = CollectionsUtil.newArrayList(); - javaFileSrcDirs.add(new File("src/test/java")); - context.setJavaSrcFileDirs(javaFileSrcDirs); - context.setEntityMetaFactory(new EntityMetaFactoryImpl(new TableMetaFactoryImpl(), new PropertyMetaFactoryImpl( - new ColumnMetaFactoryImpl()))); - entityMetaReader = new DefaultEntityMetaReaderFactory().createEntityMetaReader(context); - List<EntityMeta> entityMetas = entityMetaReader.read(); - - EntityMeta em = entityMetas.get(0); - if ("depertment".equals(em.getName())) { - // entity name null check - assertThat(em.getName(), is(notNullValue())); - // entity name equal check - assertThat(em.getName(), is("depertment")); - LOG.debug(em.toString()); - - // property null check - assertThat(em.getPropertyMeta("depertmentId"), is(notNullValue())); - assertThat(em.getPropertyMeta("depertmentName"), is(notNullValue())); - assertThat(em.getPropertyMeta("version"), is(notNullValue())); - /* - // comment null check - assertThat(EntityMetaUtil.getComment(em), is(notNullValue())); - assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("depertmentId")), is(notNullValue())); - assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("depertmentName")), is(notNullValue())); - assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("version")), is(notNullValue())); - // comment equal check - assertThat(EntityMetaUtil.getComment(em), is("部署")); - assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("depertmentId")), is("部署ID")); - assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("depertmentName")), is("部署名")); - assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("version")), is("バージョン")); - */ - // property name null check - assertThat(em.getPropertyMeta("depertmentId").getName(), is(notNullValue())); - assertThat(em.getPropertyMeta("depertmentName").getName(), is(notNullValue())); - assertThat(em.getPropertyMeta("version").getName(), is(notNullValue())); - // property name equal check - assertThat(em.getPropertyMeta("depertmentId").getName(), is("depertmentId")); - assertThat(em.getPropertyMeta("depertmentName").getName(), is("depertmentName")); - assertThat(em.getPropertyMeta("version").getName(), is("version")); - // property class null check - assertThat(em.getPropertyMeta("depertmentId").getPropertyClass(), is(notNullValue())); - assertThat(em.getPropertyMeta("depertmentName").getPropertyClass(), is(notNullValue())); - assertThat(em.getPropertyMeta("version").getPropertyClass(), is(notNullValue())); - // property class name null check - assertThat(em.getPropertyMeta("depertmentId").getPropertyClass().getName(), is(notNullValue())); - assertThat(em.getPropertyMeta("depertmentName").getPropertyClass().getName(), is(notNullValue())); - assertThat(em.getPropertyMeta("version").getPropertyClass().getName(), is(notNullValue())); - // property class name equal check - assertThat(em.getPropertyMeta("depertmentId").getPropertyClass().getName(), is("java.lang.Long")); - assertThat(em.getPropertyMeta("depertmentName").getPropertyClass().getName(), is("java.lang.String")); - assertThat(em.getPropertyMeta("version").getPropertyClass().getName(), is("java.lang.Long")); - // column name null check - assertThat(em.getPropertyMeta("depertmentId").getColumnMeta().getName(), is(notNullValue())); - assertThat(em.getPropertyMeta("depertmentName").getColumnMeta().getName(), is(notNullValue())); - assertThat(em.getPropertyMeta("version").getColumnMeta().getName(), is(notNullValue())); - // column name equal check - assertThat(em.getPropertyMeta("depertmentId").getColumnMeta().getName(), is("DEPERTMENT_ID")); - assertThat(em.getPropertyMeta("depertmentName").getColumnMeta().getName(), is("DEPERTMENT_NAME")); - assertThat(em.getPropertyMeta("version").getColumnMeta().getName(), is("VERSION")); - - // property attribute check - assertThat(em.getPropertyMeta("depertmentId").isId(), is(true)); - assertThat(em.getPropertyMeta("version").isVersion(), is(true)); - } - em = entityMetas.get(1); - if ("employee".equals(em.getName())) { - // entity name null check - assertThat(em.getName(), is(notNullValue())); - // entity name equal check - assertThat(em.getName(), is("employee")); - LOG.debug(em.toString()); - // property null check - assertThat(em.getPropertyMeta("employeeId"), is(notNullValue())); - assertThat(em.getPropertyMeta("employeeName"), is(notNullValue())); - assertThat(em.getPropertyMeta("version"), is(notNullValue())); - assertThat(em.getPropertyMeta("depertment"), is(notNullValue())); - /* - // comment null check - assertThat(EntityMetaUtil.getComment(em), is("従業員")); - assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("employeeId")), is(notNullValue())); - assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("employeeName")), is(notNullValue())); - assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("version")), is(notNullValue())); - // comment equal check - assertThat(EntityMetaUtil.getComment(em), is("従業員")); - assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("employeeId")), is("従業員ID")); - assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("employeeName")), is("従業員名")); - assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("version")), is("バージョン")); - */ - // property name null check - assertThat(em.getPropertyMeta("employeeId").getName(), is(notNullValue())); - assertThat(em.getPropertyMeta("employeeName").getName(), is(notNullValue())); - assertThat(em.getPropertyMeta("version").getName(), is(notNullValue())); - // property name equal check - assertThat(em.getPropertyMeta("employeeId").getName(), is("employeeId")); - assertThat(em.getPropertyMeta("employeeName").getName(), is("employeeName")); - assertThat(em.getPropertyMeta("version").getName(), is("version")); - // property class null check - assertThat(em.getPropertyMeta("employeeId").getPropertyClass(), is(notNullValue())); - assertThat(em.getPropertyMeta("employeeName").getPropertyClass(), is(notNullValue())); - assertThat(em.getPropertyMeta("version").getPropertyClass(), is(notNullValue())); - // property class name null check - assertThat(em.getPropertyMeta("employeeId").getPropertyClass().getName(), is(notNullValue())); - assertThat(em.getPropertyMeta("employeeName").getPropertyClass().getName(), is(notNullValue())); - assertThat(em.getPropertyMeta("version").getPropertyClass().getName(), is(notNullValue())); - // property class name equal check - assertThat(em.getPropertyMeta("employeeId").getPropertyClass().getName(), is("java.lang.Long")); - assertThat(em.getPropertyMeta("employeeName").getPropertyClass().getName(), is("java.lang.String")); - assertThat(em.getPropertyMeta("version").getPropertyClass().getName(), is("java.lang.Long")); - // column name null check - assertThat(em.getPropertyMeta("employeeId").getColumnMeta().getName(), is(notNullValue())); - assertThat(em.getPropertyMeta("employeeName").getColumnMeta().getName(), is(notNullValue())); - assertThat(em.getPropertyMeta("version").getColumnMeta().getName(), is(notNullValue())); - // column name equal check - assertThat(em.getPropertyMeta("employeeId").getColumnMeta().getName(), is("EMPLOYEE_ID")); - assertThat(em.getPropertyMeta("employeeName").getColumnMeta().getName(), is("EMPLOYEE_NAME")); - assertThat(em.getPropertyMeta("version").getColumnMeta().getName(), is("VERSION")); - // property attribute check - assertThat(em.getPropertyMeta("employeeId").isId(), is(true)); - assertThat(em.getPropertyMeta("version").isVersion(), is(true)); - assertThat(em.getPropertyMeta("depertment").isRelationship(), is(true)); - assertThat(em.getPropertyMeta("depertment").getRelationshipClass(), is(notNullValue())); - assertThat(em.getPropertyMeta("depertment").getRelationshipType(), is(notNullValue())); - assertThat(em.getPropertyMeta("depertment").getRelationshipClass().getName(), - is("example.entity.Depertment")); - assertThat(em.getPropertyMeta("depertment").getRelationshipType(), is(RelationshipType.MANY_TO_ONE)); - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.impl; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +import java.io.File; +import java.util.List; + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jiemamy.entity.io.meta.DefaultEntityMetaReaderContext; +import org.jiemamy.entity.io.meta.DefaultEntityMetaReaderFactory; +import org.jiemamy.entity.io.meta.EntityMeta; +import org.jiemamy.entity.io.meta.EntityMetaReader; +import org.jiemamy.entity.io.meta.RelationshipType; +import org.jiemamy.utils.CollectionsUtil; +import org.jiemamy.utils.ResourceUtil; + +/** + * TODO for kato + * + * @author kato + */ +public class EntityMetaReaderImplTest { + + private EntityMetaReader entityMetaReader; + + private static final Logger LOG = LoggerFactory.getLogger(EntityMetaReaderImplTest.class); + + + /** + * Test method for {@link org.jiemamy.entity.io.meta.impl.EntityMetaReaderImpl#read()}. + * @throws Exception 例外 + */ + @Test + public void testRead() throws Exception { + DefaultEntityMetaReaderContext context = new DefaultEntityMetaReaderContext(); + context.setJavaFileEncoding("UTF-8"); + List<File> classPathDirs = CollectionsUtil.newArrayList(); + classPathDirs.add(ResourceUtil.getBuildDirNoException(example.entity.Employee.class).getCanonicalFile()); + context.setClassPathDirs(classPathDirs); + context.setPackageName("example.entity"); + context.setReadComment(true); + List<File> javaFileSrcDirs = CollectionsUtil.newArrayList(); + javaFileSrcDirs.add(new File("src/test/java")); + context.setJavaSrcFileDirs(javaFileSrcDirs); + context.setEntityMetaFactory(new EntityMetaFactoryImpl(new TableMetaFactoryImpl(), new PropertyMetaFactoryImpl( + new ColumnMetaFactoryImpl()))); + entityMetaReader = new DefaultEntityMetaReaderFactory().createEntityMetaReader(context); + List<EntityMeta> entityMetas = entityMetaReader.read(); + + EntityMeta em = entityMetas.get(0); + if ("depertment".equals(em.getName())) { + // entity name null check + assertThat(em.getName(), is(notNullValue())); + // entity name equal check + assertThat(em.getName(), is("depertment")); + LOG.debug(em.toString()); + + // property null check + assertThat(em.getPropertyMeta("depertmentId"), is(notNullValue())); + assertThat(em.getPropertyMeta("depertmentName"), is(notNullValue())); + assertThat(em.getPropertyMeta("version"), is(notNullValue())); + /* + // comment null check + assertThat(EntityMetaUtil.getComment(em), is(notNullValue())); + assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("depertmentId")), is(notNullValue())); + assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("depertmentName")), is(notNullValue())); + assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("version")), is(notNullValue())); + // comment equal check + assertThat(EntityMetaUtil.getComment(em), is("部署")); + assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("depertmentId")), is("部署ID")); + assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("depertmentName")), is("部署名")); + assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("version")), is("バージョン")); + */ + // property name null check + assertThat(em.getPropertyMeta("depertmentId").getName(), is(notNullValue())); + assertThat(em.getPropertyMeta("depertmentName").getName(), is(notNullValue())); + assertThat(em.getPropertyMeta("version").getName(), is(notNullValue())); + // property name equal check + assertThat(em.getPropertyMeta("depertmentId").getName(), is("depertmentId")); + assertThat(em.getPropertyMeta("depertmentName").getName(), is("depertmentName")); + assertThat(em.getPropertyMeta("version").getName(), is("version")); + // property class null check + assertThat(em.getPropertyMeta("depertmentId").getPropertyClass(), is(notNullValue())); + assertThat(em.getPropertyMeta("depertmentName").getPropertyClass(), is(notNullValue())); + assertThat(em.getPropertyMeta("version").getPropertyClass(), is(notNullValue())); + // property class name null check + assertThat(em.getPropertyMeta("depertmentId").getPropertyClass().getName(), is(notNullValue())); + assertThat(em.getPropertyMeta("depertmentName").getPropertyClass().getName(), is(notNullValue())); + assertThat(em.getPropertyMeta("version").getPropertyClass().getName(), is(notNullValue())); + // property class name equal check + assertThat(em.getPropertyMeta("depertmentId").getPropertyClass().getName(), is("java.lang.Long")); + assertThat(em.getPropertyMeta("depertmentName").getPropertyClass().getName(), is("java.lang.String")); + assertThat(em.getPropertyMeta("version").getPropertyClass().getName(), is("java.lang.Long")); + // column name null check + assertThat(em.getPropertyMeta("depertmentId").getColumnMeta().getName(), is(notNullValue())); + assertThat(em.getPropertyMeta("depertmentName").getColumnMeta().getName(), is(notNullValue())); + assertThat(em.getPropertyMeta("version").getColumnMeta().getName(), is(notNullValue())); + // column name equal check + assertThat(em.getPropertyMeta("depertmentId").getColumnMeta().getName(), is("DEPERTMENT_ID")); + assertThat(em.getPropertyMeta("depertmentName").getColumnMeta().getName(), is("DEPERTMENT_NAME")); + assertThat(em.getPropertyMeta("version").getColumnMeta().getName(), is("VERSION")); + + // property attribute check + assertThat(em.getPropertyMeta("depertmentId").isId(), is(true)); + assertThat(em.getPropertyMeta("version").isVersion(), is(true)); + } + em = entityMetas.get(1); + if ("employee".equals(em.getName())) { + // entity name null check + assertThat(em.getName(), is(notNullValue())); + // entity name equal check + assertThat(em.getName(), is("employee")); + LOG.debug(em.toString()); + // property null check + assertThat(em.getPropertyMeta("employeeId"), is(notNullValue())); + assertThat(em.getPropertyMeta("employeeName"), is(notNullValue())); + assertThat(em.getPropertyMeta("version"), is(notNullValue())); + assertThat(em.getPropertyMeta("depertment"), is(notNullValue())); + /* + // comment null check + assertThat(EntityMetaUtil.getComment(em), is("従業員")); + assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("employeeId")), is(notNullValue())); + assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("employeeName")), is(notNullValue())); + assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("version")), is(notNullValue())); + // comment equal check + assertThat(EntityMetaUtil.getComment(em), is("従業員")); + assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("employeeId")), is("従業員ID")); + assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("employeeName")), is("従業員名")); + assertThat(PropertyMetaUtil.getComment(em.getPropertyMeta("version")), is("バージョン")); + */ + // property name null check + assertThat(em.getPropertyMeta("employeeId").getName(), is(notNullValue())); + assertThat(em.getPropertyMeta("employeeName").getName(), is(notNullValue())); + assertThat(em.getPropertyMeta("version").getName(), is(notNullValue())); + // property name equal check + assertThat(em.getPropertyMeta("employeeId").getName(), is("employeeId")); + assertThat(em.getPropertyMeta("employeeName").getName(), is("employeeName")); + assertThat(em.getPropertyMeta("version").getName(), is("version")); + // property class null check + assertThat(em.getPropertyMeta("employeeId").getPropertyClass(), is(notNullValue())); + assertThat(em.getPropertyMeta("employeeName").getPropertyClass(), is(notNullValue())); + assertThat(em.getPropertyMeta("version").getPropertyClass(), is(notNullValue())); + // property class name null check + assertThat(em.getPropertyMeta("employeeId").getPropertyClass().getName(), is(notNullValue())); + assertThat(em.getPropertyMeta("employeeName").getPropertyClass().getName(), is(notNullValue())); + assertThat(em.getPropertyMeta("version").getPropertyClass().getName(), is(notNullValue())); + // property class name equal check + assertThat(em.getPropertyMeta("employeeId").getPropertyClass().getName(), is("java.lang.Long")); + assertThat(em.getPropertyMeta("employeeName").getPropertyClass().getName(), is("java.lang.String")); + assertThat(em.getPropertyMeta("version").getPropertyClass().getName(), is("java.lang.Long")); + // column name null check + assertThat(em.getPropertyMeta("employeeId").getColumnMeta().getName(), is(notNullValue())); + assertThat(em.getPropertyMeta("employeeName").getColumnMeta().getName(), is(notNullValue())); + assertThat(em.getPropertyMeta("version").getColumnMeta().getName(), is(notNullValue())); + // column name equal check + assertThat(em.getPropertyMeta("employeeId").getColumnMeta().getName(), is("EMPLOYEE_ID")); + assertThat(em.getPropertyMeta("employeeName").getColumnMeta().getName(), is("EMPLOYEE_NAME")); + assertThat(em.getPropertyMeta("version").getColumnMeta().getName(), is("VERSION")); + // property attribute check + assertThat(em.getPropertyMeta("employeeId").isId(), is(true)); + assertThat(em.getPropertyMeta("version").isVersion(), is(true)); + assertThat(em.getPropertyMeta("depertment").isRelationship(), is(true)); + assertThat(em.getPropertyMeta("depertment").getRelationshipClass(), is(notNullValue())); + assertThat(em.getPropertyMeta("depertment").getRelationshipType(), is(notNullValue())); + assertThat(em.getPropertyMeta("depertment").getRelationshipClass().getName(), + is("example.entity.Depertment")); + assertThat(em.getPropertyMeta("depertment").getRelationshipType(), is(RelationshipType.MANY_TO_ONE)); + } + } +} Property changes on: leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/EntityMetaReaderImplTest.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/TestDialect.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/TestDialect.java 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/TestDialect.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,241 +1,241 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 14, 2009 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.entity.io.meta.impl; - -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.sql.Types; -import java.util.HashMap; -import java.util.Map; - -import javax.persistence.GenerationType; - -import org.jiemamy.JiemamyFactory; -import org.jiemamy.dialect.Dialect; -import org.jiemamy.entity.io.gen.dialect.GenDialect; -import org.jiemamy.entity.io.utils.CaseInsensitiveMap; -import org.jiemamy.entity.io.utils.ColumnUtil; - -/** - * TODO for kato - * - * @author kato - */ -public class TestDialect implements GenDialect { - - /** - * 標準の{@link ColumnType}の実装クラスです。 - * - * @author j5ik2o - */ - public static class StandardColumnType implements ColumnType { - - private static final StandardColumnType BIGINT = new StandardColumnType("bigint", Long.class); - - private static final StandardColumnType BINARY = new StandardColumnType("binary", byte[].class); - - private static final StandardColumnType BIT = new StandardColumnType("bit", Boolean.class); - - private static final StandardColumnType BLOB = new StandardColumnType("blob", byte[].class, true); - - private static final StandardColumnType BOOLEAN = new StandardColumnType("boolean", Boolean.class); - - private static final StandardColumnType CHAR = new StandardColumnType("char($l)", String.class); - - private static final StandardColumnType CLOB = new StandardColumnType("clob", String.class, true); - - private static final StandardColumnType DATE = new StandardColumnType("date", java.sql.Date.class); - - private static final StandardColumnType DECIMAL = new StandardColumnType("decimal", BigDecimal.class); - - private static final StandardColumnType DOUBLE = new StandardColumnType("double", Double.class); - - private static final StandardColumnType FLOAT = new StandardColumnType("float", Float.class); - - private static final StandardColumnType INTEGER = new StandardColumnType("integer", Integer.class); - - private static final StandardColumnType LONGVARBINARY = new StandardColumnType("longvarbinary", byte[].class); - - private static final StandardColumnType LONGVARCHAR = new StandardColumnType("longvarchar", String.class); - - private static final StandardColumnType NUMERIC = new StandardColumnType("numeric", BigDecimal.class); - - private static final StandardColumnType REAL = new StandardColumnType("real", Float.class); - - private static final StandardColumnType SMALLINT = new StandardColumnType("smallint", Short.class); - - private static final StandardColumnType TIME = new StandardColumnType("time", java.sql.Time.class); - - private static final StandardColumnType TIMESTAMP = new StandardColumnType("timestamp", Timestamp.class); - - private static final StandardColumnType TINYINT = new StandardColumnType("tinyint", Short.class); - - private static final StandardColumnType VARBINARY = new StandardColumnType("varbinary($l)", byte[].class); - - private static final StandardColumnType VARCHAR = new StandardColumnType("varchar($l)", String.class); - - /** カラム定義 */ - protected String dataType; - - /** 属性のクラス */ - protected Class<?> attributeClass; - - /** LOBの場合{@code true} */ - protected boolean lob; - - - /** - * インスタンスを構築する。 - * - * @param dataType データ型 - * @param attributeClass 属性のクラス - */ - protected StandardColumnType(String dataType, Class<?> attributeClass) { - this(dataType, attributeClass, false); - } - - /** - * インスタンスを構築する。 - * - * @param dataType カラム定義 - * @param attributeClass 属性のクラス - * @param lob LOBの場合{@code true} - */ - protected StandardColumnType(String dataType, Class<?> attributeClass, boolean lob) { - this.dataType = dataType; - this.attributeClass = attributeClass; - this.lob = lob; - } - - public Class<?> getAttributeClass(int length, int precision, int scale) { - return attributeClass; - } - - public String getColumnDefinition(int length, int precision, int scale, String defaultValue) { - String completeDataType = ColumnUtil.formatDataType(dataType, length, precision, scale); - return getColumnDefinitionInternal(completeDataType, defaultValue); - } - - /** - * カラム定義を取得する。 - * - * @param completeDataType 完全なデータ型 - * @param defaultValue デフォルト値、存在しない場合は{@code null} - * @return カラム定義 - */ - protected String getColumnDefinitionInternal(String completeDataType, String defaultValue) { - if (defaultValue == null) { - return completeDataType; - } - return completeDataType + " default " + defaultValue; - } - - public boolean isLob() { - return lob; - } - - } - - - private Dialect dialect; - - private JiemamyFactory factory; - - /** カラムの型名をキー、{@link GenDialect.ColumnType}を値とするマップ */ - @SuppressWarnings("unchecked") - protected Map<Object, ColumnType> columnTypeMap = new CaseInsensitiveMap(); - - /** カラムのSQL型をキー、{@link GenDialect.ColumnType}を値とするマップ。 */ - protected Map<Integer, ColumnType> fallbackColumnTypeMap = new HashMap<Integer, ColumnType>(); - - - /** - * インスタンスを生成する。 - * - * @param factory - * @param dialect - */ - public TestDialect(final JiemamyFactory factory, final Dialect dialect) { - this.factory = factory; - this.dialect = dialect; - columnTypeMap.put("bigint", StandardColumnType.BIGINT); - columnTypeMap.put("binary", StandardColumnType.BINARY); - columnTypeMap.put("bit", StandardColumnType.BIT); - columnTypeMap.put("blob", StandardColumnType.BLOB); - columnTypeMap.put("boolean", StandardColumnType.BOOLEAN); - columnTypeMap.put("char", StandardColumnType.CHAR); - columnTypeMap.put("clob", StandardColumnType.CLOB); - columnTypeMap.put("date", StandardColumnType.DATE); - columnTypeMap.put("decimal", StandardColumnType.DECIMAL); - columnTypeMap.put("double", StandardColumnType.DOUBLE); - columnTypeMap.put("float", StandardColumnType.FLOAT); - columnTypeMap.put("integer", StandardColumnType.INTEGER); - columnTypeMap.put("longvarbinary", StandardColumnType.LONGVARBINARY); - columnTypeMap.put("longvarchar", StandardColumnType.LONGVARCHAR); - columnTypeMap.put("numeric", StandardColumnType.NUMERIC); - columnTypeMap.put("real", StandardColumnType.REAL); - columnTypeMap.put("smallint", StandardColumnType.SMALLINT); - columnTypeMap.put("time", StandardColumnType.TIME); - columnTypeMap.put("timestamp", StandardColumnType.TIMESTAMP); - columnTypeMap.put("tinyint", StandardColumnType.TINYINT); - columnTypeMap.put("varbinary", StandardColumnType.VARBINARY); - columnTypeMap.put("varchar", StandardColumnType.VARCHAR); - - fallbackColumnTypeMap.put(Types.BIGINT, StandardColumnType.BIGINT); - fallbackColumnTypeMap.put(Types.BINARY, StandardColumnType.BINARY); - fallbackColumnTypeMap.put(Types.BIT, StandardColumnType.BIT); - fallbackColumnTypeMap.put(Types.BLOB, StandardColumnType.BLOB); - fallbackColumnTypeMap.put(Types.BOOLEAN, StandardColumnType.BOOLEAN); - fallbackColumnTypeMap.put(Types.CHAR, StandardColumnType.CHAR); - fallbackColumnTypeMap.put(Types.CLOB, StandardColumnType.CLOB); - fallbackColumnTypeMap.put(Types.DATE, StandardColumnType.DATE); - fallbackColumnTypeMap.put(Types.DECIMAL, StandardColumnType.DECIMAL); - fallbackColumnTypeMap.put(Types.DOUBLE, StandardColumnType.DOUBLE); - fallbackColumnTypeMap.put(Types.FLOAT, StandardColumnType.FLOAT); - fallbackColumnTypeMap.put(Types.INTEGER, StandardColumnType.INTEGER); - fallbackColumnTypeMap.put(Types.LONGVARBINARY, StandardColumnType.LONGVARBINARY); - fallbackColumnTypeMap.put(Types.LONGVARCHAR, StandardColumnType.LONGVARCHAR); - fallbackColumnTypeMap.put(Types.NUMERIC, StandardColumnType.NUMERIC); - fallbackColumnTypeMap.put(Types.REAL, StandardColumnType.REAL); - fallbackColumnTypeMap.put(Types.SMALLINT, StandardColumnType.SMALLINT); - fallbackColumnTypeMap.put(Types.TIME, StandardColumnType.TIME); - fallbackColumnTypeMap.put(Types.TIMESTAMP, StandardColumnType.TIMESTAMP); - fallbackColumnTypeMap.put(Types.TINYINT, StandardColumnType.TINYINT); - fallbackColumnTypeMap.put(Types.VARBINARY, StandardColumnType.VARBINARY); - fallbackColumnTypeMap.put(Types.VARCHAR, StandardColumnType.VARCHAR); - } - - public ColumnType getColumnType(String columnTypeName, int sqlType) { - ColumnType columnType = columnTypeMap.get(columnTypeName); - return columnType != null ? columnType : fallbackColumnTypeMap.get(sqlType); - } - - public GenerationType getDefaultGenerationType() { - return GenerationType.IDENTITY; - } - - public String getName() { - return "testDialect"; - } - - public boolean supportsIdentity() { - return true; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 14, 2009 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.entity.io.meta.impl; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.sql.Types; +import java.util.HashMap; +import java.util.Map; + +import javax.persistence.GenerationType; + +import org.jiemamy.JiemamyFactory; +import org.jiemamy.dialect.Dialect; +import org.jiemamy.entity.io.gen.dialect.GenDialect; +import org.jiemamy.entity.io.utils.CaseInsensitiveMap; +import org.jiemamy.entity.io.utils.ColumnUtil; + +/** + * TODO for kato + * + * @author kato + */ +public class TestDialect implements GenDialect { + + /** + * 標準の{@link ColumnType}の実装クラスです。 + * + * @author j5ik2o + */ + public static class StandardColumnType implements ColumnType { + + private static final StandardColumnType BIGINT = new StandardColumnType("bigint", Long.class); + + private static final StandardColumnType BINARY = new StandardColumnType("binary", byte[].class); + + private static final StandardColumnType BIT = new StandardColumnType("bit", Boolean.class); + + private static final StandardColumnType BLOB = new StandardColumnType("blob", byte[].class, true); + + private static final StandardColumnType BOOLEAN = new StandardColumnType("boolean", Boolean.class); + + private static final StandardColumnType CHAR = new StandardColumnType("char($l)", String.class); + + private static final StandardColumnType CLOB = new StandardColumnType("clob", String.class, true); + + private static final StandardColumnType DATE = new StandardColumnType("date", java.sql.Date.class); + + private static final StandardColumnType DECIMAL = new StandardColumnType("decimal", BigDecimal.class); + + private static final StandardColumnType DOUBLE = new StandardColumnType("double", Double.class); + + private static final StandardColumnType FLOAT = new StandardColumnType("float", Float.class); + + private static final StandardColumnType INTEGER = new StandardColumnType("integer", Integer.class); + + private static final StandardColumnType LONGVARBINARY = new StandardColumnType("longvarbinary", byte[].class); + + private static final StandardColumnType LONGVARCHAR = new StandardColumnType("longvarchar", String.class); + + private static final StandardColumnType NUMERIC = new StandardColumnType("numeric", BigDecimal.class); + + private static final StandardColumnType REAL = new StandardColumnType("real", Float.class); + + private static final StandardColumnType SMALLINT = new StandardColumnType("smallint", Short.class); + + private static final StandardColumnType TIME = new StandardColumnType("time", java.sql.Time.class); + + private static final StandardColumnType TIMESTAMP = new StandardColumnType("timestamp", Timestamp.class); + + private static final StandardColumnType TINYINT = new StandardColumnType("tinyint", Short.class); + + private static final StandardColumnType VARBINARY = new StandardColumnType("varbinary($l)", byte[].class); + + private static final StandardColumnType VARCHAR = new StandardColumnType("varchar($l)", String.class); + + /** カラム定義 */ + protected String dataType; + + /** 属性のクラス */ + protected Class<?> attributeClass; + + /** LOBの場合{@code true} */ + protected boolean lob; + + + /** + * インスタンスを構築する。 + * + * @param dataType データ型 + * @param attributeClass 属性のクラス + */ + protected StandardColumnType(String dataType, Class<?> attributeClass) { + this(dataType, attributeClass, false); + } + + /** + * インスタンスを構築する。 + * + * @param dataType カラム定義 + * @param attributeClass 属性のクラス + * @param lob LOBの場合{@code true} + */ + protected StandardColumnType(String dataType, Class<?> attributeClass, boolean lob) { + this.dataType = dataType; + this.attributeClass = attributeClass; + this.lob = lob; + } + + public Class<?> getAttributeClass(int length, int precision, int scale) { + return attributeClass; + } + + public String getColumnDefinition(int length, int precision, int scale, String defaultValue) { + String completeDataType = ColumnUtil.formatDataType(dataType, length, precision, scale); + return getColumnDefinitionInternal(completeDataType, defaultValue); + } + + /** + * カラム定義を取得する。 + * + * @param completeDataType 完全なデータ型 + * @param defaultValue デフォルト値、存在しない場合は{@code null} + * @return カラム定義 + */ + protected String getColumnDefinitionInternal(String completeDataType, String defaultValue) { + if (defaultValue == null) { + return completeDataType; + } + return completeDataType + " default " + defaultValue; + } + + public boolean isLob() { + return lob; + } + + } + + + private Dialect dialect; + + private JiemamyFactory factory; + + /** カラムの型名をキー、{@link GenDialect.ColumnType}を値とするマップ */ + @SuppressWarnings("unchecked") + protected Map<Object, ColumnType> columnTypeMap = new CaseInsensitiveMap(); + + /** カラムのSQL型をキー、{@link GenDialect.ColumnType}を値とするマップ。 */ + protected Map<Integer, ColumnType> fallbackColumnTypeMap = new HashMap<Integer, ColumnType>(); + + + /** + * インスタンスを生成する。 + * + * @param factory + * @param dialect + */ + public TestDialect(final JiemamyFactory factory, final Dialect dialect) { + this.factory = factory; + this.dialect = dialect; + columnTypeMap.put("bigint", StandardColumnType.BIGINT); + columnTypeMap.put("binary", StandardColumnType.BINARY); + columnTypeMap.put("bit", StandardColumnType.BIT); + columnTypeMap.put("blob", StandardColumnType.BLOB); + columnTypeMap.put("boolean", StandardColumnType.BOOLEAN); + columnTypeMap.put("char", StandardColumnType.CHAR); + columnTypeMap.put("clob", StandardColumnType.CLOB); + columnTypeMap.put("date", StandardColumnType.DATE); + columnTypeMap.put("decimal", StandardColumnType.DECIMAL); + columnTypeMap.put("double", StandardColumnType.DOUBLE); + columnTypeMap.put("float", StandardColumnType.FLOAT); + columnTypeMap.put("integer", StandardColumnType.INTEGER); + columnTypeMap.put("longvarbinary", StandardColumnType.LONGVARBINARY); + columnTypeMap.put("longvarchar", StandardColumnType.LONGVARCHAR); + columnTypeMap.put("numeric", StandardColumnType.NUMERIC); + columnTypeMap.put("real", StandardColumnType.REAL); + columnTypeMap.put("smallint", StandardColumnType.SMALLINT); + columnTypeMap.put("time", StandardColumnType.TIME); + columnTypeMap.put("timestamp", StandardColumnType.TIMESTAMP); + columnTypeMap.put("tinyint", StandardColumnType.TINYINT); + columnTypeMap.put("varbinary", StandardColumnType.VARBINARY); + columnTypeMap.put("varchar", StandardColumnType.VARCHAR); + + fallbackColumnTypeMap.put(Types.BIGINT, StandardColumnType.BIGINT); + fallbackColumnTypeMap.put(Types.BINARY, StandardColumnType.BINARY); + fallbackColumnTypeMap.put(Types.BIT, StandardColumnType.BIT); + fallbackColumnTypeMap.put(Types.BLOB, StandardColumnType.BLOB); + fallbackColumnTypeMap.put(Types.BOOLEAN, StandardColumnType.BOOLEAN); + fallbackColumnTypeMap.put(Types.CHAR, StandardColumnType.CHAR); + fallbackColumnTypeMap.put(Types.CLOB, StandardColumnType.CLOB); + fallbackColumnTypeMap.put(Types.DATE, StandardColumnType.DATE); + fallbackColumnTypeMap.put(Types.DECIMAL, StandardColumnType.DECIMAL); + fallbackColumnTypeMap.put(Types.DOUBLE, StandardColumnType.DOUBLE); + fallbackColumnTypeMap.put(Types.FLOAT, StandardColumnType.FLOAT); + fallbackColumnTypeMap.put(Types.INTEGER, StandardColumnType.INTEGER); + fallbackColumnTypeMap.put(Types.LONGVARBINARY, StandardColumnType.LONGVARBINARY); + fallbackColumnTypeMap.put(Types.LONGVARCHAR, StandardColumnType.LONGVARCHAR); + fallbackColumnTypeMap.put(Types.NUMERIC, StandardColumnType.NUMERIC); + fallbackColumnTypeMap.put(Types.REAL, StandardColumnType.REAL); + fallbackColumnTypeMap.put(Types.SMALLINT, StandardColumnType.SMALLINT); + fallbackColumnTypeMap.put(Types.TIME, StandardColumnType.TIME); + fallbackColumnTypeMap.put(Types.TIMESTAMP, StandardColumnType.TIMESTAMP); + fallbackColumnTypeMap.put(Types.TINYINT, StandardColumnType.TINYINT); + fallbackColumnTypeMap.put(Types.VARBINARY, StandardColumnType.VARBINARY); + fallbackColumnTypeMap.put(Types.VARCHAR, StandardColumnType.VARCHAR); + } + + public ColumnType getColumnType(String columnTypeName, int sqlType) { + ColumnType columnType = columnTypeMap.get(columnTypeName); + return columnType != null ? columnType : fallbackColumnTypeMap.get(sqlType); + } + + public GenerationType getDefaultGenerationType() { + return GenerationType.IDENTITY; + } + + public String getName() { + return "testDialect"; + } + + public boolean supportsIdentity() { + return true; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/TestDialect.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/test/resources/META-INF/maven/org.jiemamy/jiemamy-entity-io/pom.properties =================================================================== --- leto/jiemamy-entity-io/trunk/src/test/resources/META-INF/maven/org.jiemamy/jiemamy-entity-io/pom.properties 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/test/resources/META-INF/maven/org.jiemamy/jiemamy-entity-io/pom.properties 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,4 +1,4 @@ -#test -version=test-0.0.1 -groupId=test-org.seasar.container -artifactId=test-s2jdbc-gen +#test +version=test-0.0.1 +groupId=test-org.seasar.container +artifactId=test-s2jdbc-gen Property changes on: leto/jiemamy-entity-io/trunk/src/test/resources/META-INF/maven/org.jiemamy/jiemamy-entity-io/pom.properties ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: leto/jiemamy-entity-io/trunk/src/test/resources/logback.xml =================================================================== --- leto/jiemamy-entity-io/trunk/src/test/resources/logback.xml 2009-09-20 17:23:12 UTC (rev 3643) +++ leto/jiemamy-entity-io/trunk/src/test/resources/logback.xml 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,18 +1,18 @@ -<?xml version="1.0" encoding="UTF-8"?> -<configuration> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <Target>System.out</Target> - <layout class="ch.qos.logback.classic.PatternLayout"> - <Pattern>%d{HH:mm:ss.SSS z,JST} [%thread] %-5level %logger{36} - %msg%n</Pattern> - </layout> - </appender> - - <root> - <level value="WARN" /> - <appender-ref ref="STDOUT" /> - </root> - - <logger name="org.jiemamy.utils.enhancer"> - <level value="TRACE" /> - </logger> -</configuration> +<?xml version="1.0" encoding="UTF-8"?> +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <Target>System.out</Target> + <layout class="ch.qos.logback.classic.PatternLayout"> + <Pattern>%d{HH:mm:ss.SSS z,JST} [%thread] %-5level %logger{36} - %msg%n</Pattern> + </layout> + </appender> + + <root> + <level value="WARN" /> + <appender-ref ref="STDOUT" /> + </root> + + <logger name="org.jiemamy.utils.enhancer"> + <level value="TRACE" /> + </logger> +</configuration> Property changes on: leto/jiemamy-entity-io/trunk/src/test/resources/logback.xml ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/LICENSE.txt =================================================================== --- zeus/trunk/jiemamy-test-helper/LICENSE.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/LICENSE.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. Property changes on: zeus/trunk/jiemamy-test-helper/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/license/LICENSE.hamcrest.txt =================================================================== --- zeus/trunk/jiemamy-test-helper/license/LICENSE.hamcrest.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/license/LICENSE.hamcrest.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,27 +1,27 @@ -BSD License - -Copyright (c) 2000-2006, www.hamcrest.org -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of -conditions and the following disclaimer. Redistributions in binary form must reproduce -the above copyright notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -Neither the name of Hamcrest nor the names of its contributors may be used to endorse -or promote products derived from this software without specific prior written -permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT -SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY -WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. +BSD License + +Copyright (c) 2000-2006, www.hamcrest.org +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. Redistributions in binary form must reproduce +the above copyright notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the distribution. + +Neither the name of Hamcrest nor the names of its contributors may be used to endorse +or promote products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. Property changes on: zeus/trunk/jiemamy-test-helper/license/LICENSE.hamcrest.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: zeus/trunk/jiemamy-test-helper/license/LICENSE.junit.html ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/html Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/license/LICENSE.logback.txt =================================================================== --- zeus/trunk/jiemamy-test-helper/license/LICENSE.logback.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/license/LICENSE.logback.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,22 +1,22 @@ -Logback LICENSE ---------------- - -Logback: the reliable, generic, fast and flexible logging library for -Java. - -Copyright (C) 2000-2008, QOS.ch - -Source code and binaries for logback, including logback-core, -logback-classic and logback-access modules, are distributed under the -GNU Lesser General Public License Version 2.1, as published by the -Free Software Foundation. - -This library 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 2.1 of the -License, or (at your option) any later version. - -This library 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. +Logback LICENSE +--------------- + +Logback: the reliable, generic, fast and flexible logging library for +Java. + +Copyright (C) 2000-2008, QOS.ch + +Source code and binaries for logback, including logback-core, +logback-classic and logback-access modules, are distributed under the +GNU Lesser General Public License Version 2.1, as published by the +Free Software Foundation. + +This library 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 2.1 of the +License, or (at your option) any later version. + +This library 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. Property changes on: zeus/trunk/jiemamy-test-helper/license/LICENSE.logback.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/license/LICENSE.slf4j.txt =================================================================== --- zeus/trunk/jiemamy-test-helper/license/LICENSE.slf4j.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/license/LICENSE.slf4j.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,24 +1,24 @@ -Copyright (c) 2004-2008 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - +Copyright (c) 2004-2008 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + Property changes on: zeus/trunk/jiemamy-test-helper/license/LICENSE.slf4j.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/license/list.txt =================================================================== --- zeus/trunk/jiemamy-test-helper/license/list.txt 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/license/list.txt 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,17 +1,17 @@ -MIT License: - SLF4J API Module, - JCL 1.1.1 implemented over SLF4J - -BSD style: - Hamcrest Core, - Hamcrest Library, - -Common Public License Version 1.0: - JUnit - -GNU Lesser General Public License: - Logback Classic Module, - Logback Core Module - -The Apache Software License, Version 2.0: - Factory Enhancer +MIT License: + SLF4J API Module, + JCL 1.1.1 implemented over SLF4J + +BSD style: + Hamcrest Core, + Hamcrest Library, + +Common Public License Version 1.0: + JUnit + +GNU Lesser General Public License: + Logback Classic Module, + Logback Core Module + +The Apache Software License, Version 2.0: + Factory Enhancer Property changes on: zeus/trunk/jiemamy-test-helper/license/list.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/pom.xml =================================================================== --- zeus/trunk/jiemamy-test-helper/pom.xml 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/pom.xml 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,109 +1,109 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.jiemamy</groupId> - <artifactId>master</artifactId> - <version>1.1</version> - </parent> - <groupId>org.jiemamy</groupId> - <artifactId>jiemamy-test-helper</artifactId> - <name>Jiemamy Test Helper</name> - <version>0.3.0-SNAPSHOT</version> - <url>http://report.jiemamy.org/jiemamy-test-helper</url> - <ciManagement> - <system>hudson</system> - <url>http://hudson.jiemamy.org/hudson/job/jiemamy-test-helper/</url> - <notifiers> - <notifier> - <sendOnSuccess>false</sendOnSuccess> - <configuration> - <recipients>jiema****@googl*****</recipients> - </configuration> - </notifier> - </notifiers> - </ciManagement> - <inceptionYear>2009</inceptionYear> - <developers> - <developer> - <id>daisuke</id> - <name>MIYAMOTO Daisuke</name> - <email>daisuke_m****@users*****</email> - <url>http://d.hatena.ne.jp/daisuke-m/</url> - <timezone>+9</timezone> - </developer> - <developer> - <id>j5ik2o</id> - <name>Junichi Kato</name> - <email>j5ik2****@users*****</email> - <url>http://d.hatena.ne.jp/j5ik2o/</url> - <timezone>+9</timezone> - </developer> - </developers> - <scm> - <connection>scm:svn:http://svn.sourceforge.jp/svnroot/jiemamy/leto/jiemamy-test-helper/trunk</connection> - <developerConnection>scm:svn:svn+ssh://svn.sourceforge.jp/svnroot/jiemamy/leto/jiemamy-test-helper/trunk</developerConnection> - <url>http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi/leto/jiemamy-test-helper/trunk/?root=jiemamy</url> - </scm> - <repositories> - <repository> - <id>jiemamy.org</id> - <name>Jiemamy Repository</name> - <url>http://maven.jiemamy.org/release</url> - </repository> - </repositories> - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.5</version> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <version>1.1</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>1.5.6</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> - <version>1.5.6</version> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-core</artifactId> - <version>0.9.15</version> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <version>0.9.15</version> - </dependency> - <dependency> - <groupId>net.sourceforge.collections</groupId> - <artifactId>collections-generic</artifactId> - <version>4.01</version> - </dependency> - <dependency> - <groupId>org.jiemamy</groupId> - <artifactId>jiemamy-spec-core</artifactId> - <version>0.3-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.jiemamy</groupId> - <artifactId>jiemamy-spec-view</artifactId> - <version>0.3-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.jiemamy</groupId> - <artifactId>jiemamy-commons</artifactId> - <version>0.0.3</version> - </dependency> - </dependencies> +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.jiemamy</groupId> + <artifactId>master</artifactId> + <version>1.1</version> + </parent> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-test-helper</artifactId> + <name>Jiemamy Test Helper</name> + <version>0.3.0-SNAPSHOT</version> + <url>http://report.jiemamy.org/jiemamy-test-helper</url> + <ciManagement> + <system>hudson</system> + <url>http://hudson.jiemamy.org/hudson/job/jiemamy-test-helper/</url> + <notifiers> + <notifier> + <sendOnSuccess>false</sendOnSuccess> + <configuration> + <recipients>jiema****@googl*****</recipients> + </configuration> + </notifier> + </notifiers> + </ciManagement> + <inceptionYear>2009</inceptionYear> + <developers> + <developer> + <id>daisuke</id> + <name>MIYAMOTO Daisuke</name> + <email>daisuke_m****@users*****</email> + <url>http://d.hatena.ne.jp/daisuke-m/</url> + <timezone>+9</timezone> + </developer> + <developer> + <id>j5ik2o</id> + <name>Junichi Kato</name> + <email>j5ik2****@users*****</email> + <url>http://d.hatena.ne.jp/j5ik2o/</url> + <timezone>+9</timezone> + </developer> + </developers> + <scm> + <connection>scm:svn:http://svn.sourceforge.jp/svnroot/jiemamy/leto/jiemamy-test-helper/trunk</connection> + <developerConnection>scm:svn:svn+ssh://svn.sourceforge.jp/svnroot/jiemamy/leto/jiemamy-test-helper/trunk</developerConnection> + <url>http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi/leto/jiemamy-test-helper/trunk/?root=jiemamy</url> + </scm> + <repositories> + <repository> + <id>jiemamy.org</id> + <name>Jiemamy Repository</name> + <url>http://maven.jiemamy.org/release</url> + </repository> + </repositories> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-library</artifactId> + <version>1.1</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.5.6</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>1.5.6</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>0.9.15</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>0.9.15</version> + </dependency> + <dependency> + <groupId>net.sourceforge.collections</groupId> + <artifactId>collections-generic</artifactId> + <version>4.01</version> + </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-spec-core</artifactId> + <version>0.3-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-spec-view</artifactId> + <version>0.3-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-commons</artifactId> + <version>0.0.3</version> + </dependency> + </dependencies> </project> \ No newline at end of file Property changes on: zeus/trunk/jiemamy-test-helper/pom.xml ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/AbstractTestModelBuilder.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/AbstractTestModelBuilder.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/AbstractTestModelBuilder.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,38 +1,38 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/09/02 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test; - -import org.jiemamy.Jiemamy; -import org.jiemamy.internal.test.mock.MockDialect; - -/** - * {@link TestModelBuilder}の骨格実装。 - * - * @author daisuke - */ -public abstract class AbstractTestModelBuilder implements TestModelBuilder { - - private static final String DIALECT_CLASS_NAME = MockDialect.class.getName(); - - - public Jiemamy build() { - return build(DIALECT_CLASS_NAME); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/09/02 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test; + +import org.jiemamy.Jiemamy; +import org.jiemamy.internal.test.mock.MockDialect; + +/** + * {@link TestModelBuilder}の骨格実装。 + * + * @author daisuke + */ +public abstract class AbstractTestModelBuilder implements TestModelBuilder { + + private static final String DIALECT_CLASS_NAME = MockDialect.class.getName(); + + + public Jiemamy build() { + return build(DIALECT_CLASS_NAME); + } + +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/AbstractTestModelBuilder.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,780 +1,780 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/22 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.jiemamy.Jiemamy; -import org.jiemamy.JiemamyFactory; -import org.jiemamy.ServiceLocator; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.attribute.ColumnModel; -import org.jiemamy.model.attribute.RepresentationAdapter; -import org.jiemamy.model.attribute.constraint.ColumnCheckConstraint; -import org.jiemamy.model.attribute.constraint.Deferrability; -import org.jiemamy.model.attribute.constraint.ForeignKey; -import org.jiemamy.model.attribute.constraint.NotNullConstraint; -import org.jiemamy.model.attribute.constraint.PrimaryKey; -import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime; -import org.jiemamy.model.attribute.constraint.ForeignKey.ReferentialAction; -import org.jiemamy.model.dataset.DataSetModel; -import org.jiemamy.model.dataset.RecordModel; -import org.jiemamy.model.datatype.BuiltinDataType; -import org.jiemamy.model.datatype.DataTypeCategory; -import org.jiemamy.model.datatype.DomainModel; -import org.jiemamy.model.datatype.DomainRef; -import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; -import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; -import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; -import org.jiemamy.model.entity.TableModel; -import org.jiemamy.model.entity.ViewModel; -import org.jiemamy.model.index.IndexColumnModel; -import org.jiemamy.model.index.IndexModel; -import org.jiemamy.model.index.IndexColumnModel.SortOrder; -import org.jiemamy.model.script.Position; -import org.jiemamy.utils.CollectionsUtil; -import org.jiemamy.utils.Disablable; - -/** - * Jiemamyテストモデル1(EMP-DEPTテーブル)を組み立てるビルダ。 - * - * @author daisuke - */ -public class CoreTestModelBuilder extends AbstractTestModelBuilder { - - // ---- basics - - /** UUID生成戦略 */ - public final UuidStrategy uuid; - - /** 生成方針 */ - public final Instruction instruction; - - /** 生成するモデルのインスタンス空間 */ - public final Jiemamy jiemamy; - - /** 生成に使用するファクトリ */ - public final JiemamyFactory factory; - - // ---- models - - /** 生成したモデル */ - public final RootModel rootModel; - - /** 生成したモデル */ - public DomainModel domainId; - - // dept - - /** 生成したモデル */ - public DomainModel domainName; - - /** 生成したモデル */ - public TableModel tableDept; - - /** 生成したモデル */ - public ColumnModel deptId; - - /** 生成したモデル */ - public ColumnModel deptDeptNo; - - /** 生成したモデル */ - public ColumnModel deptDeptName; - - /** 生成したモデル */ - public ColumnModel deptLoc; - - // emp - - /** 生成したモデル */ - public PrimaryKey deptPk; - - /** 生成したモデル */ - public TableModel tableEmp; - - /** 生成したモデル */ - public ColumnModel empId; - - /** 生成したモデル */ - public ColumnModel empEmpNo; - - /** 生成したモデル */ - - public ColumnModel empEmpName; - - /** 生成したモデル */ - public ColumnModel empMgrId; - - /** 生成したモデル */ - public ColumnModel empHiredate; - - /** 生成したモデル */ - public ColumnModel empSal; - - /** 生成したモデル */ - public ColumnModel empDeptId; - - // highSal - - /** 生成したモデル */ - public PrimaryKey empPk; - - // fk - - /** 生成したモデル */ - public ViewModel viewHighSal; - - /** 生成したモデル */ - public ForeignKey fkEmpEmp; - - /** 生成したモデル */ - public ForeignKey fkEmpDept; - - private IndexModel empNameIndex; - - - /** - * インスタンスを生成する。 - */ - public CoreTestModelBuilder() { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param instruction 設定オブジェクト - */ - public CoreTestModelBuilder(Instruction instruction) { - this(UuidStrategy.FIXED, instruction, Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param instruction 設定オブジェクト - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder(Instruction instruction, Jiemamy jiemamy) { - this(UuidStrategy.FIXED, instruction, jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder(Jiemamy jiemamy) { - this(UuidStrategy.FIXED, new Instruction(), jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param serviceLocator サービスロケータ - */ - public CoreTestModelBuilder(ServiceLocator serviceLocator) { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance(serviceLocator)); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - */ - public CoreTestModelBuilder(UuidStrategy uuid) { - this(uuid, new Instruction(), Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param instruction 設定オブジェクト - */ - public CoreTestModelBuilder(UuidStrategy uuid, Instruction instruction) { - this(uuid, instruction, Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param instruction 設定オブジェクト - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder(UuidStrategy uuid, Instruction instruction, Jiemamy jiemamy) { - this.uuid = uuid; - this.instruction = instruction; - this.jiemamy = jiemamy; - factory = jiemamy.getFactory(); - - if (factory.hasRootModel() && uuid == UuidStrategy.FIXED) { - throw new IllegalArgumentException(); - } - rootModel = jiemamy.getFactory().getRootModel(uuid.get("d5a96af3-b1e9-4285-a8ef-c491ce5ae308")); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder(UuidStrategy uuid, Jiemamy jiemamy) { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); - } - - public Jiemamy build(String dialectClassName) { - rootModel.setDialectClassName(dialectClassName); - rootModel.setDescription("Jiemamyテストモデル1"); - rootModel.setSchemaName("FOO"); - - createDomains(); - createEntities(); - createForeignKeys(); - createDataSets(); - - return jiemamy; - } - - /** - * ビルドしたモデルを持つJiemamyオブジェクトを取得する。 - * - * @return Jiemamyオブジェクト - */ - public Jiemamy getJiemamy() { - return jiemamy; - } - - /** - * データセットを生成する。 - */ - protected void createDataSets() { - if (instruction.supressUseDataSet) { - return; - } - // データセットの生成・追加(1) - DataSetModel dataSetEn = factory.newModel(DataSetModel.class, uuid.get("b73100b5-2d70-4b48-a825-311eacb63b2f")); - dataSetEn.setName("データ群en"); - dataSetEn.getRecords().put(factory.newReference(tableDept), createDataSetEnDept()); - dataSetEn.getRecords().put(factory.newReference(tableEmp), createDataSetEnEmp()); - rootModel.getDataSets().add(dataSetEn); - - // データセットの生成・追加(2) - DataSetModel dataSetJa = factory.newModel(DataSetModel.class, uuid.get("91246ed4-1ef3-440e-bf12-40fa4439a71b")); - dataSetJa.setName("データ群ja"); - dataSetJa.getRecords().put(factory.newReference(tableDept), createDataSetJaDept()); - dataSetJa.getRecords().put(factory.newReference(tableEmp), createDataSetJaEmp()); - rootModel.getDataSets().add(dataSetJa); - } - - /** - * ドメインを生成する。 - */ - protected void createDomains() { - if (instruction.supressUseDomain) { - return; - } - - domainId = factory.newModel(DomainModel.class, uuid.get("2eec0aa0-5122-4eb7-833d-9f5a43e7abe9")); - domainId.setName("ID"); - domainId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - NotNullConstraint notNull = - factory.newModel(NotNullConstraint.class, uuid.get("af4845dc-7f3a-434d-b5ac-2f25b74d7e76")); - domainId.setNotNullConstraint(notNull); - ColumnCheckConstraint check = - factory.newModel(ColumnCheckConstraint.class, uuid.get("48b76d76-b288-480a-afa4-111247379f8d")); - check.setName("hoge"); - check.setExpression("VALUE > 0"); - domainId.setCheckConstraint(check); - if (domainId.getDataType().hasAdapter(SerialDataTypeAdapter.class)) { - domainId.getDataType().getAdapter(SerialDataTypeAdapter.class).setSerial(true); - } - rootModel.getDomains().add(domainId); - - domainName = factory.newModel(DomainModel.class, uuid.get("62f1e6ec-e6aa-4d52-a6c3-27dac086f2d7")); - domainName.setName("NAME"); - BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); - dataType.getAdapter(SizedDataTypeAdapter.class).setSize(32); // CHECKSTYLE IGNORE THIS LINE - domainName.setDataType(dataType); - domainName.setDescription("人名用の型です。"); - rootModel.getDomains().add(domainName); - } - - /** - * エンティティを生成する。 - */ - protected void createEntities() { - createTableDept(); - rootModel.getEntities().add(tableDept); - createTableEmp(); - rootModel.getEntities().add(tableEmp); - createViewHighSal(); - rootModel.getEntities().add(viewHighSal); - } - - /** - * 外部キーを生成する。 - */ - protected void createForeignKeys() { - if (instruction.supressUseForeignKey) { - return; - } - - int pkIndex = tableEmp.getAttributes().indexOf(empPk); - - fkEmpEmp = factory.newModel(ForeignKey.class, uuid.get("e43d3c43-33c8-4b02-aa42-83f2d868cfe6")); - fkEmpEmp.setName("emp_mgr_id_fkey"); - fkEmpEmp.getKeyColumns().add(factory.newReference(empMgrId)); - fkEmpEmp.getReferenceColumns().add(factory.newReference(empId)); - fkEmpEmp.setOnDelete(ReferentialAction.SET_NULL); - Deferrability deferrability = - factory.newModel(Deferrability.class, uuid.get("9af096ba-8841-41ba-9dd4-02628b800bf0")); - deferrability.setDeferrable(true); - deferrability.setInitiallyCheckTime(InitiallyCheckTime.DEFERRED); - fkEmpEmp.setDeferrability(deferrability); - tableEmp.getAttributes().add(pkIndex + 1, fkEmpEmp); - - fkEmpDept = factory.newModel(ForeignKey.class, uuid.get("e7dd92b4-1d97-4be6-bab6-fa9fe26eb6ed")); - fkEmpDept.setName("emp_dept_id_fkey"); - fkEmpDept.getKeyColumns().add(factory.newReference(empDeptId)); - fkEmpDept.getReferenceColumns().add(factory.newReference(deptId)); - tableEmp.getAttributes().add(pkIndex + 2, fkEmpDept); - } - - private List<RecordModel> createDataSetEnDept() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - // CHECKSTYLE:OFF - RecordModel record = factory.newModel(RecordModel.class, uuid.get("176bfb08-99cb-4c76-bf8e-6979e0c7afb9")); - ModelUtil.addValue(record, deptId, "1"); - ModelUtil.addValue(record, deptDeptNo, "10"); - ModelUtil.addValue(record, deptDeptName, "ACCOUNTING"); - ModelUtil.addValue(record, deptLoc, "NEW YORK"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("3971430b-ef1d-4e5a-b996-f2acfa7536c0")); - ModelUtil.addValue(record, deptId, "2"); - ModelUtil.addValue(record, deptDeptNo, "20"); - ModelUtil.addValue(record, deptDeptName, "RESEARCH"); - ModelUtil.addValue(record, deptLoc, "DALLAS"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("0591cc1e-45a6-4598-b85a-20fae51b7991")); - ModelUtil.addValue(record, deptId, "3"); - ModelUtil.addValue(record, deptDeptNo, "30"); - ModelUtil.addValue(record, deptDeptName, "SALES"); - ModelUtil.addValue(record, deptLoc, "CHICAGO"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("ac275955-4710-484a-b694-f7acc6ded08f")); - ModelUtil.addValue(record, deptId, "4"); - ModelUtil.addValue(record, deptDeptNo, "40"); - ModelUtil.addValue(record, deptDeptName, "OPERATIONS"); - ModelUtil.addValue(record, deptLoc, "BOSTON"); - result.add(record); - // CHECKSTYLE:ON - - return result; - } - - private List<RecordModel> createDataSetEnEmp() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - // CHECKSTYLE:OFF - RecordModel record = factory.newModel(RecordModel.class, uuid.get("6ce22d69-bd75-4822-946f-a51221fd45eb")); - ModelUtil.addValue(record, empId, "1"); - ModelUtil.addValue(record, empEmpNo, "10"); - ModelUtil.addValue(record, empEmpName, "SMITH"); - ModelUtil.addValue(record, empMgrId, "3"); - ModelUtil.addValue(record, empHiredate, "2003-02-01"); - ModelUtil.addValue(record, empSal, "40"); - ModelUtil.addValue(record, empDeptId, "3"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("03962eb2-90ab-4cff-8fac-14e52e117361")); - ModelUtil.addValue(record, empId, "2"); - ModelUtil.addValue(record, empEmpNo, "20"); - ModelUtil.addValue(record, empEmpName, "ALLEN"); - ModelUtil.addValue(record, empMgrId, "3"); - ModelUtil.addValue(record, empHiredate, "2000-03-04"); - ModelUtil.addValue(record, empSal, "50"); - ModelUtil.addValue(record, empDeptId, "4"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("f5f16c1e-4a41-4ccd-9c87-00c09c0e7609")); - ModelUtil.addValue(record, empId, "3"); - ModelUtil.addValue(record, empEmpNo, "30"); - ModelUtil.addValue(record, empEmpName, "WARD"); -// ModelUtil.addValue(record, empMgrId, null); - ModelUtil.addValue(record, empHiredate, "1993-12-05"); - ModelUtil.addValue(record, empSal, "60"); - ModelUtil.addValue(record, empDeptId, "4"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("03a9e57f-3010-4d46-8024-1915c262749e")); - ModelUtil.addValue(record, empId, "4"); - ModelUtil.addValue(record, empEmpNo, "40"); - ModelUtil.addValue(record, empEmpName, "JONES"); - ModelUtil.addValue(record, empMgrId, "2"); - ModelUtil.addValue(record, empHiredate, "2007-04-01"); - ModelUtil.addValue(record, empSal, "36"); - ModelUtil.addValue(record, empDeptId, "2"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("4206acce-b31f-4c2e-8682-4796254a4dca")); - ModelUtil.addValue(record, empId, "5"); - ModelUtil.addValue(record, empEmpNo, "50"); - ModelUtil.addValue(record, empEmpName, "MARTIN"); - ModelUtil.addValue(record, empMgrId, "1"); - ModelUtil.addValue(record, empHiredate, "2002-05-30"); - ModelUtil.addValue(record, empSal, "30"); - ModelUtil.addValue(record, empDeptId, "3"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("6748ce0e-462d-44df-a536-18f14a3c2643")); - ModelUtil.addValue(record, empId, "6"); - ModelUtil.addValue(record, empEmpNo, "60"); - ModelUtil.addValue(record, empEmpName, "BLAKE"); - ModelUtil.addValue(record, empMgrId, "3"); - ModelUtil.addValue(record, empHiredate, "2007-04-01"); - ModelUtil.addValue(record, empSal, "25"); - ModelUtil.addValue(record, empDeptId, "2"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("f8564bdf-f61c-4711-b606-69aed74324a6")); - ModelUtil.addValue(record, empId, "7"); - ModelUtil.addValue(record, empEmpNo, "70"); - ModelUtil.addValue(record, empEmpName, "CLARK"); - ModelUtil.addValue(record, empMgrId, "1"); - ModelUtil.addValue(record, empHiredate, "2004-09-01"); - ModelUtil.addValue(record, empSal, "30"); - ModelUtil.addValue(record, empDeptId, "1"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("dd1cc8e1-7562-4539-86d8-5390d043325a")); - ModelUtil.addValue(record, empId, "8"); - ModelUtil.addValue(record, empEmpNo, "80"); - ModelUtil.addValue(record, empEmpName, "SCOTT"); - ModelUtil.addValue(record, empMgrId, "4"); - ModelUtil.addValue(record, empHiredate, "2008-03-01"); - ModelUtil.addValue(record, empSal, "25"); - ModelUtil.addValue(record, empDeptId, "2"); - result.add(record); - // CHECKSTYLE:ON - - return result; - } - - private List<RecordModel> createDataSetJaDept() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - // CHECKSTYLE:OFF - RecordModel record = factory.newModel(RecordModel.class, uuid.get("61671217-d61c-4f42-9985-4f6b2c970171")); - ModelUtil.addValue(record, deptId, "1"); - ModelUtil.addValue(record, deptDeptNo, "10"); - ModelUtil.addValue(record, deptDeptName, "経理部"); - ModelUtil.addValue(record, deptLoc, "広島"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("171d019e-163f-42f6-82dc-15340798fdf4")); - ModelUtil.addValue(record, deptId, "2"); - ModelUtil.addValue(record, deptDeptNo, "20"); - ModelUtil.addValue(record, deptDeptName, "研究開発部"); - ModelUtil.addValue(record, deptLoc, "京都"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("838344e6-093d-4202-aaca-bacf1a7ff376")); - ModelUtil.addValue(record, deptId, "3"); - ModelUtil.addValue(record, deptDeptNo, "30"); - ModelUtil.addValue(record, deptDeptName, "営業部"); - ModelUtil.addValue(record, deptLoc, "東京"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("2f29bb19-0a20-4251-8052-568194e6101c")); - ModelUtil.addValue(record, deptId, "4"); - ModelUtil.addValue(record, deptDeptNo, "40"); - ModelUtil.addValue(record, deptDeptName, "経営本部"); - // locは指定せず、特定しない状態 - result.add(record); - // CHECKSTYLE:ON - - return result; - } - - private List<RecordModel> createDataSetJaEmp() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - // CHECKSTYLE:OFF - RecordModel record = factory.newModel(RecordModel.class, uuid.get("9365e670-1eff-4a23-90bd-f794b9742b10")); - ModelUtil.addValue(record, empId, "1"); - ModelUtil.addValue(record, empEmpNo, "10"); - ModelUtil.addValue(record, empEmpName, "鈴木 茂"); - ModelUtil.addValue(record, empMgrId, "3"); - ModelUtil.addValue(record, empHiredate, "2003-02-01"); - ModelUtil.addValue(record, empSal, "40"); - ModelUtil.addValue(record, empDeptId, "3"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("90673863-ba77-461b-ab82-fffecd7e873b")); - ModelUtil.addValue(record, empId, "2"); - ModelUtil.addValue(record, empEmpNo, "20"); - ModelUtil.addValue(record, empEmpName, "内海 透"); - ModelUtil.addValue(record, empMgrId, "3"); - ModelUtil.addValue(record, empHiredate, "2000-03-04"); - ModelUtil.addValue(record, empSal, "50"); - ModelUtil.addValue(record, empDeptId, "4"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("5bf32699-c2ff-4d96-9e26-2a3f3d7c7661")); - ModelUtil.addValue(record, empId, "3"); - ModelUtil.addValue(record, empEmpNo, "30"); - ModelUtil.addValue(record, empEmpName, "村瀬 武彦"); -// ModelUtil.addValue(record, empMgrId, null); - ModelUtil.addValue(record, empHiredate, "1993-12-05"); - ModelUtil.addValue(record, empSal, "60"); - ModelUtil.addValue(record, empDeptId, "4"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("f164796f-ed85-48a0-98af-2f6045ee3a33")); - ModelUtil.addValue(record, empId, "4"); - ModelUtil.addValue(record, empEmpNo, "40"); - ModelUtil.addValue(record, empEmpName, "近藤 美樹"); - ModelUtil.addValue(record, empMgrId, "2"); - ModelUtil.addValue(record, empHiredate, "2007-04-01"); - ModelUtil.addValue(record, empSal, "36"); - ModelUtil.addValue(record, empDeptId, "2"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("c10562ee-4ab9-40a5-8a21-83f331df5c85")); - ModelUtil.addValue(record, empId, "5"); - ModelUtil.addValue(record, empEmpNo, "50"); - ModelUtil.addValue(record, empEmpName, "榊 美子"); - ModelUtil.addValue(record, empMgrId, "1"); - ModelUtil.addValue(record, empHiredate, "2002-05-30"); - ModelUtil.addValue(record, empSal, "30"); - ModelUtil.addValue(record, empDeptId, "3"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("29c9a655-f4ed-4753-aea6-1e21cb28f891")); - ModelUtil.addValue(record, empId, "6"); - ModelUtil.addValue(record, empEmpNo, "60"); - ModelUtil.addValue(record, empEmpName, "三浦 佑"); - ModelUtil.addValue(record, empMgrId, "3"); - ModelUtil.addValue(record, empHiredate, "2007-04-01"); - ModelUtil.addValue(record, empSal, "25"); - ModelUtil.addValue(record, empDeptId, "2"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("b65b9b12-bb68-4845-a514-a57f0bd57616")); - ModelUtil.addValue(record, empId, "7"); - ModelUtil.addValue(record, empEmpNo, "70"); - ModelUtil.addValue(record, empEmpName, "前島 孝幸"); - ModelUtil.addValue(record, empMgrId, "1"); - ModelUtil.addValue(record, empHiredate, "2004-09-01"); - ModelUtil.addValue(record, empSal, "30"); - ModelUtil.addValue(record, empDeptId, "1"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("0eb27151-323a-4679-bde4-0b01f561139f")); - ModelUtil.addValue(record, empId, "8"); - ModelUtil.addValue(record, empEmpNo, "80"); - ModelUtil.addValue(record, empEmpName, "島崎 由比"); - ModelUtil.addValue(record, empMgrId, "4"); - ModelUtil.addValue(record, empHiredate, "2008-03-01"); - ModelUtil.addValue(record, empSal, "25"); - ModelUtil.addValue(record, empDeptId, "2"); - result.add(record); - // CHECKSTYLE:ON - - return result; - } - - private void createTableDept() { - tableDept = factory.newModel(TableModel.class, uuid.get("d7489ed6-0add-443d-95cf-234376eb0455")); - tableDept.setName("T_DEPT"); - - tableDept.getAroundScript().setScript(Position.BEGIN, "/* test begin script */"); - - tableDept.setDescription("部署マスタです。"); - - deptId = factory.newModel(ColumnModel.class, uuid.get("c7ed225d-92a6-4cc2-90de-60531804464e")); - deptId.setName("ID"); - if (instruction.supressUseDomain) { - deptId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - } else { - DomainRef ref = factory.newReference(domainId); - deptId.setDataType(ref); - } - deptId.setLogicalName("部署ID"); - deptPk = factory.newModel(PrimaryKey.class, uuid.get("8de55e65-ec48-467a-bac5-8eee2d71d41c")); - deptPk.setName("dept_pkey"); - deptPk.getKeyColumns().add(factory.newReference(deptId)); - deptId.setPrimaryKey(deptPk); - tableDept.getAttributes().add(deptId); - - deptDeptNo = factory.newModel(ColumnModel.class, uuid.get("2d951389-6bc7-49d7-8631-1d26fe17047e")); - deptDeptNo.setName("DEPT_NO"); - deptDeptNo.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - deptDeptNo.setLogicalName("部署番号"); - tableDept.getAttributes().add(deptDeptNo); - - deptDeptName = factory.newModel(ColumnModel.class, uuid.get("1fcd63d3-974e-4d2e-a0d8-3b9c233104d9")); - deptDeptName.setName("DEPT_NAME"); - BuiltinDataType deptDeptNameDataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); - deptDeptNameDataType.getAdapter(SizedDataTypeAdapter.class).setSize(20); - deptDeptName.setDataType(deptDeptNameDataType); - deptDeptName.setLogicalName("部署名"); - deptDeptName.getAdapter(RepresentationAdapter.class).setRepresentation(true); - tableDept.getAttributes().add(deptDeptName); - - deptLoc = factory.newModel(ColumnModel.class, uuid.get("7bf79e76-07b8-43b6-a993-b8ef374a31f5")); - deptLoc.setName("LOC"); - BuiltinDataType deptLocDataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); - deptLocDataType.getAdapter(SizedDataTypeAdapter.class).setSize(20); - deptLoc.setDataType(deptLocDataType); - deptLoc.setLogicalName("ロケーション"); - deptLoc.setDefaultValue("secret"); - tableDept.getAttributes().add(deptLoc); - - Map<UUID, UUID> columnNotNullMap = CollectionsUtil.newHashMap(); - columnNotNullMap.put(deptDeptNo.getId(), uuid.get("cc709f63-a886-4207-a316-58ad7f279e10")); - columnNotNullMap.put(deptDeptName.getId(), uuid.get("fab2f883-0489-4661-bd57-f04286188eef")); - - for (ColumnModel columnModel : Arrays.asList(deptDeptNo, deptDeptName)) { - NotNullConstraint notNull = - factory.newModel(NotNullConstraint.class, columnNotNullMap.get(columnModel.getId())); - columnModel.setNotNullConstraint(notNull); - } - } - - private void createTableEmp() { // CHECKSTYLE IGNORE THIS LINE - tableEmp = factory.newModel(TableModel.class, uuid.get("9f522e56-809c-45fd-8416-39201014218b")); - tableEmp.setName("T_EMP"); - tableEmp.setLogicalName("従業員"); - - tableEmp.getAroundScript().setScript(Position.BEGIN, "/* test end script */"); - - tableEmp.setDescription("従業員マスタです。"); - - empId = factory.newModel(ColumnModel.class, uuid.get("44c8e93d-b7ad-46cc-9b29-88c3a7d6c33e")); - empId.setName("ID"); - if (instruction.supressUseDomain) { - empId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - } else { - DomainRef ref = factory.newReference(domainId); - empId.setDataType(ref); - } - empId.setLogicalName("従業員ID"); - tableEmp.getAttributes().add(empId); - - empEmpNo = factory.newModel(ColumnModel.class, uuid.get("248a429b-2159-4ebd-a791-eee42a059374")); - empEmpNo.setName("EMP_NO"); - empEmpNo.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - empEmpNo.setLogicalName("従業員番号"); - NotNullConstraint notNullEmpEmpNo = - factory.newModel(NotNullConstraint.class, uuid.get("05ee4c06-d8b5-4599-a7e9-1cda036ea2c7")); - notNullEmpEmpNo.getAdapter(Disablable.class).setDisabled(true); - empEmpNo.setNotNullConstraint(notNullEmpEmpNo); - tableEmp.getAttributes().add(empEmpNo); - - empEmpName = factory.newModel(ColumnModel.class, uuid.get("0e51b6df-43ab-408c-90ef-de13c6aab881")); - empEmpName.setName("EMP_NAME"); - if (instruction.supressUseDomain) { - BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); - dataType.getAdapter(SizedDataTypeAdapter.class).setSize(32); // CHECKSTYLE IGNORE THIS LINE - empEmpName.setDataType(dataType); - } else { - DomainRef ref = factory.newReference(domainName); - empEmpName.setDataType(ref); - } - empEmpName.setLogicalName("従業員名"); - empEmpName.setDefaultValue("no name"); - empEmpName.getAdapter(RepresentationAdapter.class).setRepresentation(true); - tableEmp.getAttributes().add(empEmpName); - - empMgrId = factory.newModel(ColumnModel.class, uuid.get("3d21a85a-72de-41b3-99dd-f4cb94e58d84")); - empMgrId.setName("MGR_ID"); - empMgrId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - empMgrId.setLogicalName("上司ID"); - tableEmp.getAttributes().add(empMgrId); - - empHiredate = factory.newModel(ColumnModel.class, uuid.get("f0b57eed-98ab-4c21-9855-218c592814dc")); - empHiredate.setName("HIREDATE"); - empHiredate.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.DATE)); - tableEmp.getAttributes().add(empHiredate); - - empSal = factory.newModel(ColumnModel.class, uuid.get("80786549-dc2c-4c1c-bcbd-9f6fdec911d2")); - empSal.setName("SAL"); - BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.NUMERIC); - dataType.getAdapter(PrecisionedDataTypeAdapter.class).setPrecision(7); - dataType.getAdapter(PrecisionedDataTypeAdapter.class).setScale(2); - empSal.setDataType(dataType); - tableEmp.getAttributes().add(empSal); - - ColumnCheckConstraint checkConstraint = - factory.newModel(ColumnCheckConstraint.class, uuid.get("873f6660-7a61-4c2c-87a0-e922fa03b88c")); - checkConstraint.setName("positive_sal"); - checkConstraint.setExpression("SAL >= 0"); - empSal.setCheckConstraint(checkConstraint); - - empDeptId = factory.newModel(ColumnModel.class, uuid.get("4ae69b7a-7a0e-422a-89dc-0f0cff77565b")); - empDeptId.setName("DEPT_ID"); - empDeptId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - tableEmp.getAttributes().add(empDeptId); - - empPk = factory.newModel(PrimaryKey.class, uuid.get("6145e6a0-9ff7-4033-999d-99d80392a48f")); - empPk.setName("emp_pkey"); - empPk.getKeyColumns().add(factory.newReference(empId)); - tableEmp.getAttributes().add(empPk); - - Map<UUID, UUID> columnNotNullMap = CollectionsUtil.newHashMap(); - columnNotNullMap.put(empEmpName.getId(), uuid.get("41f178b9-2cb5-4dad-a6c0-48df2d5b1300")); - columnNotNullMap.put(empHiredate.getId(), uuid.get("2d66fd73-8d6b-41d8-b6b8-daec7d6c0c53")); - columnNotNullMap.put(empSal.getId(), uuid.get("a446779a-4fb6-4a0f-8262-22daae856e85")); - columnNotNullMap.put(empDeptId.getId(), uuid.get("b9a0fdce-a965-4118-ae71-5dc7150f6d4e")); - - for (ColumnModel columnModel : Arrays.asList(empEmpName, empHiredate, empSal, empDeptId)) { - NotNullConstraint notNull = - factory.newModel(NotNullConstraint.class, columnNotNullMap.get(columnModel.getId())); - columnModel.setNotNullConstraint(notNull); - } - - empNameIndex = factory.newModel(IndexModel.class, uuid.get("9abc9e01-4cdb-42fe-a495-93b56af35a1d")); - empNameIndex.setName("IDX_EMP_NAME"); - IndexColumnModel indexColumnModel = - factory.newModel(IndexColumnModel.class, uuid.get("52d2b6aa-fff7-4c33-af13-f4d0b63e8e58")); - indexColumnModel.setColumnRef(factory.newReference(empEmpName)); - indexColumnModel.setSortOrder(SortOrder.DESC); - empNameIndex.getIndexColumns().add(indexColumnModel); - tableEmp.getIndexes().add(empNameIndex); - } - - private void createViewHighSal() { - viewHighSal = factory.newModel(ViewModel.class, uuid.get("516f7961-cb7b-48e2-990b-7fb0c750c3a4")); - viewHighSal.setName("V_HIGH_SAL_EMP"); - viewHighSal.setDefinition("SELECT * FROM T_EMP WHERE SAL > 2000;"); - viewHighSal.setLogicalName("高給取り"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/22 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.jiemamy.Jiemamy; +import org.jiemamy.JiemamyFactory; +import org.jiemamy.ServiceLocator; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.RepresentationAdapter; +import org.jiemamy.model.attribute.constraint.ColumnCheckConstraint; +import org.jiemamy.model.attribute.constraint.Deferrability; +import org.jiemamy.model.attribute.constraint.ForeignKey; +import org.jiemamy.model.attribute.constraint.NotNullConstraint; +import org.jiemamy.model.attribute.constraint.PrimaryKey; +import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime; +import org.jiemamy.model.attribute.constraint.ForeignKey.ReferentialAction; +import org.jiemamy.model.dataset.DataSetModel; +import org.jiemamy.model.dataset.RecordModel; +import org.jiemamy.model.datatype.BuiltinDataType; +import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.datatype.DomainRef; +import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.entity.ViewModel; +import org.jiemamy.model.index.IndexColumnModel; +import org.jiemamy.model.index.IndexModel; +import org.jiemamy.model.index.IndexColumnModel.SortOrder; +import org.jiemamy.model.script.Position; +import org.jiemamy.utils.CollectionsUtil; +import org.jiemamy.utils.Disablable; + +/** + * Jiemamyテストモデル1(EMP-DEPTテーブル)を組み立てるビルダ。 + * + * @author daisuke + */ +public class CoreTestModelBuilder extends AbstractTestModelBuilder { + + // ---- basics + + /** UUID生成戦略 */ + public final UuidStrategy uuid; + + /** 生成方針 */ + public final Instruction instruction; + + /** 生成するモデルのインスタンス空間 */ + public final Jiemamy jiemamy; + + /** 生成に使用するファクトリ */ + public final JiemamyFactory factory; + + // ---- models + + /** 生成したモデル */ + public final RootModel rootModel; + + /** 生成したモデル */ + public DomainModel domainId; + + // dept + + /** 生成したモデル */ + public DomainModel domainName; + + /** 生成したモデル */ + public TableModel tableDept; + + /** 生成したモデル */ + public ColumnModel deptId; + + /** 生成したモデル */ + public ColumnModel deptDeptNo; + + /** 生成したモデル */ + public ColumnModel deptDeptName; + + /** 生成したモデル */ + public ColumnModel deptLoc; + + // emp + + /** 生成したモデル */ + public PrimaryKey deptPk; + + /** 生成したモデル */ + public TableModel tableEmp; + + /** 生成したモデル */ + public ColumnModel empId; + + /** 生成したモデル */ + public ColumnModel empEmpNo; + + /** 生成したモデル */ + + public ColumnModel empEmpName; + + /** 生成したモデル */ + public ColumnModel empMgrId; + + /** 生成したモデル */ + public ColumnModel empHiredate; + + /** 生成したモデル */ + public ColumnModel empSal; + + /** 生成したモデル */ + public ColumnModel empDeptId; + + // highSal + + /** 生成したモデル */ + public PrimaryKey empPk; + + // fk + + /** 生成したモデル */ + public ViewModel viewHighSal; + + /** 生成したモデル */ + public ForeignKey fkEmpEmp; + + /** 生成したモデル */ + public ForeignKey fkEmpDept; + + private IndexModel empNameIndex; + + + /** + * インスタンスを生成する。 + */ + public CoreTestModelBuilder() { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param instruction 設定オブジェクト + */ + public CoreTestModelBuilder(Instruction instruction) { + this(UuidStrategy.FIXED, instruction, Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param instruction 設定オブジェクト + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder(Instruction instruction, Jiemamy jiemamy) { + this(UuidStrategy.FIXED, instruction, jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder(Jiemamy jiemamy) { + this(UuidStrategy.FIXED, new Instruction(), jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param serviceLocator サービスロケータ + */ + public CoreTestModelBuilder(ServiceLocator serviceLocator) { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance(serviceLocator)); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + */ + public CoreTestModelBuilder(UuidStrategy uuid) { + this(uuid, new Instruction(), Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param instruction 設定オブジェクト + */ + public CoreTestModelBuilder(UuidStrategy uuid, Instruction instruction) { + this(uuid, instruction, Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param instruction 設定オブジェクト + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder(UuidStrategy uuid, Instruction instruction, Jiemamy jiemamy) { + this.uuid = uuid; + this.instruction = instruction; + this.jiemamy = jiemamy; + factory = jiemamy.getFactory(); + + if (factory.hasRootModel() && uuid == UuidStrategy.FIXED) { + throw new IllegalArgumentException(); + } + rootModel = jiemamy.getFactory().getRootModel(uuid.get("d5a96af3-b1e9-4285-a8ef-c491ce5ae308")); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder(UuidStrategy uuid, Jiemamy jiemamy) { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); + } + + public Jiemamy build(String dialectClassName) { + rootModel.setDialectClassName(dialectClassName); + rootModel.setDescription("Jiemamyテストモデル1"); + rootModel.setSchemaName("FOO"); + + createDomains(); + createEntities(); + createForeignKeys(); + createDataSets(); + + return jiemamy; + } + + /** + * ビルドしたモデルを持つJiemamyオブジェクトを取得する。 + * + * @return Jiemamyオブジェクト + */ + public Jiemamy getJiemamy() { + return jiemamy; + } + + /** + * データセットを生成する。 + */ + protected void createDataSets() { + if (instruction.supressUseDataSet) { + return; + } + // データセットの生成・追加(1) + DataSetModel dataSetEn = factory.newModel(DataSetModel.class, uuid.get("b73100b5-2d70-4b48-a825-311eacb63b2f")); + dataSetEn.setName("データ群en"); + dataSetEn.getRecords().put(factory.newReference(tableDept), createDataSetEnDept()); + dataSetEn.getRecords().put(factory.newReference(tableEmp), createDataSetEnEmp()); + rootModel.getDataSets().add(dataSetEn); + + // データセットの生成・追加(2) + DataSetModel dataSetJa = factory.newModel(DataSetModel.class, uuid.get("91246ed4-1ef3-440e-bf12-40fa4439a71b")); + dataSetJa.setName("データ群ja"); + dataSetJa.getRecords().put(factory.newReference(tableDept), createDataSetJaDept()); + dataSetJa.getRecords().put(factory.newReference(tableEmp), createDataSetJaEmp()); + rootModel.getDataSets().add(dataSetJa); + } + + /** + * ドメインを生成する。 + */ + protected void createDomains() { + if (instruction.supressUseDomain) { + return; + } + + domainId = factory.newModel(DomainModel.class, uuid.get("2eec0aa0-5122-4eb7-833d-9f5a43e7abe9")); + domainId.setName("ID"); + domainId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + NotNullConstraint notNull = + factory.newModel(NotNullConstraint.class, uuid.get("af4845dc-7f3a-434d-b5ac-2f25b74d7e76")); + domainId.setNotNullConstraint(notNull); + ColumnCheckConstraint check = + factory.newModel(ColumnCheckConstraint.class, uuid.get("48b76d76-b288-480a-afa4-111247379f8d")); + check.setName("hoge"); + check.setExpression("VALUE > 0"); + domainId.setCheckConstraint(check); + if (domainId.getDataType().hasAdapter(SerialDataTypeAdapter.class)) { + domainId.getDataType().getAdapter(SerialDataTypeAdapter.class).setSerial(true); + } + rootModel.getDomains().add(domainId); + + domainName = factory.newModel(DomainModel.class, uuid.get("62f1e6ec-e6aa-4d52-a6c3-27dac086f2d7")); + domainName.setName("NAME"); + BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + dataType.getAdapter(SizedDataTypeAdapter.class).setSize(32); // CHECKSTYLE IGNORE THIS LINE + domainName.setDataType(dataType); + domainName.setDescription("人名用の型です。"); + rootModel.getDomains().add(domainName); + } + + /** + * エンティティを生成する。 + */ + protected void createEntities() { + createTableDept(); + rootModel.getEntities().add(tableDept); + createTableEmp(); + rootModel.getEntities().add(tableEmp); + createViewHighSal(); + rootModel.getEntities().add(viewHighSal); + } + + /** + * 外部キーを生成する。 + */ + protected void createForeignKeys() { + if (instruction.supressUseForeignKey) { + return; + } + + int pkIndex = tableEmp.getAttributes().indexOf(empPk); + + fkEmpEmp = factory.newModel(ForeignKey.class, uuid.get("e43d3c43-33c8-4b02-aa42-83f2d868cfe6")); + fkEmpEmp.setName("emp_mgr_id_fkey"); + fkEmpEmp.getKeyColumns().add(factory.newReference(empMgrId)); + fkEmpEmp.getReferenceColumns().add(factory.newReference(empId)); + fkEmpEmp.setOnDelete(ReferentialAction.SET_NULL); + Deferrability deferrability = + factory.newModel(Deferrability.class, uuid.get("9af096ba-8841-41ba-9dd4-02628b800bf0")); + deferrability.setDeferrable(true); + deferrability.setInitiallyCheckTime(InitiallyCheckTime.DEFERRED); + fkEmpEmp.setDeferrability(deferrability); + tableEmp.getAttributes().add(pkIndex + 1, fkEmpEmp); + + fkEmpDept = factory.newModel(ForeignKey.class, uuid.get("e7dd92b4-1d97-4be6-bab6-fa9fe26eb6ed")); + fkEmpDept.setName("emp_dept_id_fkey"); + fkEmpDept.getKeyColumns().add(factory.newReference(empDeptId)); + fkEmpDept.getReferenceColumns().add(factory.newReference(deptId)); + tableEmp.getAttributes().add(pkIndex + 2, fkEmpDept); + } + + private List<RecordModel> createDataSetEnDept() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + // CHECKSTYLE:OFF + RecordModel record = factory.newModel(RecordModel.class, uuid.get("176bfb08-99cb-4c76-bf8e-6979e0c7afb9")); + ModelUtil.addValue(record, deptId, "1"); + ModelUtil.addValue(record, deptDeptNo, "10"); + ModelUtil.addValue(record, deptDeptName, "ACCOUNTING"); + ModelUtil.addValue(record, deptLoc, "NEW YORK"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("3971430b-ef1d-4e5a-b996-f2acfa7536c0")); + ModelUtil.addValue(record, deptId, "2"); + ModelUtil.addValue(record, deptDeptNo, "20"); + ModelUtil.addValue(record, deptDeptName, "RESEARCH"); + ModelUtil.addValue(record, deptLoc, "DALLAS"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("0591cc1e-45a6-4598-b85a-20fae51b7991")); + ModelUtil.addValue(record, deptId, "3"); + ModelUtil.addValue(record, deptDeptNo, "30"); + ModelUtil.addValue(record, deptDeptName, "SALES"); + ModelUtil.addValue(record, deptLoc, "CHICAGO"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("ac275955-4710-484a-b694-f7acc6ded08f")); + ModelUtil.addValue(record, deptId, "4"); + ModelUtil.addValue(record, deptDeptNo, "40"); + ModelUtil.addValue(record, deptDeptName, "OPERATIONS"); + ModelUtil.addValue(record, deptLoc, "BOSTON"); + result.add(record); + // CHECKSTYLE:ON + + return result; + } + + private List<RecordModel> createDataSetEnEmp() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + // CHECKSTYLE:OFF + RecordModel record = factory.newModel(RecordModel.class, uuid.get("6ce22d69-bd75-4822-946f-a51221fd45eb")); + ModelUtil.addValue(record, empId, "1"); + ModelUtil.addValue(record, empEmpNo, "10"); + ModelUtil.addValue(record, empEmpName, "SMITH"); + ModelUtil.addValue(record, empMgrId, "3"); + ModelUtil.addValue(record, empHiredate, "2003-02-01"); + ModelUtil.addValue(record, empSal, "40"); + ModelUtil.addValue(record, empDeptId, "3"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("03962eb2-90ab-4cff-8fac-14e52e117361")); + ModelUtil.addValue(record, empId, "2"); + ModelUtil.addValue(record, empEmpNo, "20"); + ModelUtil.addValue(record, empEmpName, "ALLEN"); + ModelUtil.addValue(record, empMgrId, "3"); + ModelUtil.addValue(record, empHiredate, "2000-03-04"); + ModelUtil.addValue(record, empSal, "50"); + ModelUtil.addValue(record, empDeptId, "4"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("f5f16c1e-4a41-4ccd-9c87-00c09c0e7609")); + ModelUtil.addValue(record, empId, "3"); + ModelUtil.addValue(record, empEmpNo, "30"); + ModelUtil.addValue(record, empEmpName, "WARD"); +// ModelUtil.addValue(record, empMgrId, null); + ModelUtil.addValue(record, empHiredate, "1993-12-05"); + ModelUtil.addValue(record, empSal, "60"); + ModelUtil.addValue(record, empDeptId, "4"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("03a9e57f-3010-4d46-8024-1915c262749e")); + ModelUtil.addValue(record, empId, "4"); + ModelUtil.addValue(record, empEmpNo, "40"); + ModelUtil.addValue(record, empEmpName, "JONES"); + ModelUtil.addValue(record, empMgrId, "2"); + ModelUtil.addValue(record, empHiredate, "2007-04-01"); + ModelUtil.addValue(record, empSal, "36"); + ModelUtil.addValue(record, empDeptId, "2"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("4206acce-b31f-4c2e-8682-4796254a4dca")); + ModelUtil.addValue(record, empId, "5"); + ModelUtil.addValue(record, empEmpNo, "50"); + ModelUtil.addValue(record, empEmpName, "MARTIN"); + ModelUtil.addValue(record, empMgrId, "1"); + ModelUtil.addValue(record, empHiredate, "2002-05-30"); + ModelUtil.addValue(record, empSal, "30"); + ModelUtil.addValue(record, empDeptId, "3"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("6748ce0e-462d-44df-a536-18f14a3c2643")); + ModelUtil.addValue(record, empId, "6"); + ModelUtil.addValue(record, empEmpNo, "60"); + ModelUtil.addValue(record, empEmpName, "BLAKE"); + ModelUtil.addValue(record, empMgrId, "3"); + ModelUtil.addValue(record, empHiredate, "2007-04-01"); + ModelUtil.addValue(record, empSal, "25"); + ModelUtil.addValue(record, empDeptId, "2"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("f8564bdf-f61c-4711-b606-69aed74324a6")); + ModelUtil.addValue(record, empId, "7"); + ModelUtil.addValue(record, empEmpNo, "70"); + ModelUtil.addValue(record, empEmpName, "CLARK"); + ModelUtil.addValue(record, empMgrId, "1"); + ModelUtil.addValue(record, empHiredate, "2004-09-01"); + ModelUtil.addValue(record, empSal, "30"); + ModelUtil.addValue(record, empDeptId, "1"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("dd1cc8e1-7562-4539-86d8-5390d043325a")); + ModelUtil.addValue(record, empId, "8"); + ModelUtil.addValue(record, empEmpNo, "80"); + ModelUtil.addValue(record, empEmpName, "SCOTT"); + ModelUtil.addValue(record, empMgrId, "4"); + ModelUtil.addValue(record, empHiredate, "2008-03-01"); + ModelUtil.addValue(record, empSal, "25"); + ModelUtil.addValue(record, empDeptId, "2"); + result.add(record); + // CHECKSTYLE:ON + + return result; + } + + private List<RecordModel> createDataSetJaDept() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + // CHECKSTYLE:OFF + RecordModel record = factory.newModel(RecordModel.class, uuid.get("61671217-d61c-4f42-9985-4f6b2c970171")); + ModelUtil.addValue(record, deptId, "1"); + ModelUtil.addValue(record, deptDeptNo, "10"); + ModelUtil.addValue(record, deptDeptName, "経理部"); + ModelUtil.addValue(record, deptLoc, "広島"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("171d019e-163f-42f6-82dc-15340798fdf4")); + ModelUtil.addValue(record, deptId, "2"); + ModelUtil.addValue(record, deptDeptNo, "20"); + ModelUtil.addValue(record, deptDeptName, "研究開発部"); + ModelUtil.addValue(record, deptLoc, "京都"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("838344e6-093d-4202-aaca-bacf1a7ff376")); + ModelUtil.addValue(record, deptId, "3"); + ModelUtil.addValue(record, deptDeptNo, "30"); + ModelUtil.addValue(record, deptDeptName, "営業部"); + ModelUtil.addValue(record, deptLoc, "東京"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("2f29bb19-0a20-4251-8052-568194e6101c")); + ModelUtil.addValue(record, deptId, "4"); + ModelUtil.addValue(record, deptDeptNo, "40"); + ModelUtil.addValue(record, deptDeptName, "経営本部"); + // locは指定せず、特定しない状態 + result.add(record); + // CHECKSTYLE:ON + + return result; + } + + private List<RecordModel> createDataSetJaEmp() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + // CHECKSTYLE:OFF + RecordModel record = factory.newModel(RecordModel.class, uuid.get("9365e670-1eff-4a23-90bd-f794b9742b10")); + ModelUtil.addValue(record, empId, "1"); + ModelUtil.addValue(record, empEmpNo, "10"); + ModelUtil.addValue(record, empEmpName, "鈴木 茂"); + ModelUtil.addValue(record, empMgrId, "3"); + ModelUtil.addValue(record, empHiredate, "2003-02-01"); + ModelUtil.addValue(record, empSal, "40"); + ModelUtil.addValue(record, empDeptId, "3"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("90673863-ba77-461b-ab82-fffecd7e873b")); + ModelUtil.addValue(record, empId, "2"); + ModelUtil.addValue(record, empEmpNo, "20"); + ModelUtil.addValue(record, empEmpName, "内海 透"); + ModelUtil.addValue(record, empMgrId, "3"); + ModelUtil.addValue(record, empHiredate, "2000-03-04"); + ModelUtil.addValue(record, empSal, "50"); + ModelUtil.addValue(record, empDeptId, "4"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("5bf32699-c2ff-4d96-9e26-2a3f3d7c7661")); + ModelUtil.addValue(record, empId, "3"); + ModelUtil.addValue(record, empEmpNo, "30"); + ModelUtil.addValue(record, empEmpName, "村瀬 武彦"); +// ModelUtil.addValue(record, empMgrId, null); + ModelUtil.addValue(record, empHiredate, "1993-12-05"); + ModelUtil.addValue(record, empSal, "60"); + ModelUtil.addValue(record, empDeptId, "4"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("f164796f-ed85-48a0-98af-2f6045ee3a33")); + ModelUtil.addValue(record, empId, "4"); + ModelUtil.addValue(record, empEmpNo, "40"); + ModelUtil.addValue(record, empEmpName, "近藤 美樹"); + ModelUtil.addValue(record, empMgrId, "2"); + ModelUtil.addValue(record, empHiredate, "2007-04-01"); + ModelUtil.addValue(record, empSal, "36"); + ModelUtil.addValue(record, empDeptId, "2"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("c10562ee-4ab9-40a5-8a21-83f331df5c85")); + ModelUtil.addValue(record, empId, "5"); + ModelUtil.addValue(record, empEmpNo, "50"); + ModelUtil.addValue(record, empEmpName, "榊 美子"); + ModelUtil.addValue(record, empMgrId, "1"); + ModelUtil.addValue(record, empHiredate, "2002-05-30"); + ModelUtil.addValue(record, empSal, "30"); + ModelUtil.addValue(record, empDeptId, "3"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("29c9a655-f4ed-4753-aea6-1e21cb28f891")); + ModelUtil.addValue(record, empId, "6"); + ModelUtil.addValue(record, empEmpNo, "60"); + ModelUtil.addValue(record, empEmpName, "三浦 佑"); + ModelUtil.addValue(record, empMgrId, "3"); + ModelUtil.addValue(record, empHiredate, "2007-04-01"); + ModelUtil.addValue(record, empSal, "25"); + ModelUtil.addValue(record, empDeptId, "2"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("b65b9b12-bb68-4845-a514-a57f0bd57616")); + ModelUtil.addValue(record, empId, "7"); + ModelUtil.addValue(record, empEmpNo, "70"); + ModelUtil.addValue(record, empEmpName, "前島 孝幸"); + ModelUtil.addValue(record, empMgrId, "1"); + ModelUtil.addValue(record, empHiredate, "2004-09-01"); + ModelUtil.addValue(record, empSal, "30"); + ModelUtil.addValue(record, empDeptId, "1"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("0eb27151-323a-4679-bde4-0b01f561139f")); + ModelUtil.addValue(record, empId, "8"); + ModelUtil.addValue(record, empEmpNo, "80"); + ModelUtil.addValue(record, empEmpName, "島崎 由比"); + ModelUtil.addValue(record, empMgrId, "4"); + ModelUtil.addValue(record, empHiredate, "2008-03-01"); + ModelUtil.addValue(record, empSal, "25"); + ModelUtil.addValue(record, empDeptId, "2"); + result.add(record); + // CHECKSTYLE:ON + + return result; + } + + private void createTableDept() { + tableDept = factory.newModel(TableModel.class, uuid.get("d7489ed6-0add-443d-95cf-234376eb0455")); + tableDept.setName("T_DEPT"); + + tableDept.getAroundScript().setScript(Position.BEGIN, "/* test begin script */"); + + tableDept.setDescription("部署マスタです。"); + + deptId = factory.newModel(ColumnModel.class, uuid.get("c7ed225d-92a6-4cc2-90de-60531804464e")); + deptId.setName("ID"); + if (instruction.supressUseDomain) { + deptId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + } else { + DomainRef ref = factory.newReference(domainId); + deptId.setDataType(ref); + } + deptId.setLogicalName("部署ID"); + deptPk = factory.newModel(PrimaryKey.class, uuid.get("8de55e65-ec48-467a-bac5-8eee2d71d41c")); + deptPk.setName("dept_pkey"); + deptPk.getKeyColumns().add(factory.newReference(deptId)); + deptId.setPrimaryKey(deptPk); + tableDept.getAttributes().add(deptId); + + deptDeptNo = factory.newModel(ColumnModel.class, uuid.get("2d951389-6bc7-49d7-8631-1d26fe17047e")); + deptDeptNo.setName("DEPT_NO"); + deptDeptNo.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + deptDeptNo.setLogicalName("部署番号"); + tableDept.getAttributes().add(deptDeptNo); + + deptDeptName = factory.newModel(ColumnModel.class, uuid.get("1fcd63d3-974e-4d2e-a0d8-3b9c233104d9")); + deptDeptName.setName("DEPT_NAME"); + BuiltinDataType deptDeptNameDataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + deptDeptNameDataType.getAdapter(SizedDataTypeAdapter.class).setSize(20); + deptDeptName.setDataType(deptDeptNameDataType); + deptDeptName.setLogicalName("部署名"); + deptDeptName.getAdapter(RepresentationAdapter.class).setRepresentation(true); + tableDept.getAttributes().add(deptDeptName); + + deptLoc = factory.newModel(ColumnModel.class, uuid.get("7bf79e76-07b8-43b6-a993-b8ef374a31f5")); + deptLoc.setName("LOC"); + BuiltinDataType deptLocDataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + deptLocDataType.getAdapter(SizedDataTypeAdapter.class).setSize(20); + deptLoc.setDataType(deptLocDataType); + deptLoc.setLogicalName("ロケーション"); + deptLoc.setDefaultValue("secret"); + tableDept.getAttributes().add(deptLoc); + + Map<UUID, UUID> columnNotNullMap = CollectionsUtil.newHashMap(); + columnNotNullMap.put(deptDeptNo.getId(), uuid.get("cc709f63-a886-4207-a316-58ad7f279e10")); + columnNotNullMap.put(deptDeptName.getId(), uuid.get("fab2f883-0489-4661-bd57-f04286188eef")); + + for (ColumnModel columnModel : Arrays.asList(deptDeptNo, deptDeptName)) { + NotNullConstraint notNull = + factory.newModel(NotNullConstraint.class, columnNotNullMap.get(columnModel.getId())); + columnModel.setNotNullConstraint(notNull); + } + } + + private void createTableEmp() { // CHECKSTYLE IGNORE THIS LINE + tableEmp = factory.newModel(TableModel.class, uuid.get("9f522e56-809c-45fd-8416-39201014218b")); + tableEmp.setName("T_EMP"); + tableEmp.setLogicalName("従業員"); + + tableEmp.getAroundScript().setScript(Position.BEGIN, "/* test end script */"); + + tableEmp.setDescription("従業員マスタです。"); + + empId = factory.newModel(ColumnModel.class, uuid.get("44c8e93d-b7ad-46cc-9b29-88c3a7d6c33e")); + empId.setName("ID"); + if (instruction.supressUseDomain) { + empId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + } else { + DomainRef ref = factory.newReference(domainId); + empId.setDataType(ref); + } + empId.setLogicalName("従業員ID"); + tableEmp.getAttributes().add(empId); + + empEmpNo = factory.newModel(ColumnModel.class, uuid.get("248a429b-2159-4ebd-a791-eee42a059374")); + empEmpNo.setName("EMP_NO"); + empEmpNo.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + empEmpNo.setLogicalName("従業員番号"); + NotNullConstraint notNullEmpEmpNo = + factory.newModel(NotNullConstraint.class, uuid.get("05ee4c06-d8b5-4599-a7e9-1cda036ea2c7")); + notNullEmpEmpNo.getAdapter(Disablable.class).setDisabled(true); + empEmpNo.setNotNullConstraint(notNullEmpEmpNo); + tableEmp.getAttributes().add(empEmpNo); + + empEmpName = factory.newModel(ColumnModel.class, uuid.get("0e51b6df-43ab-408c-90ef-de13c6aab881")); + empEmpName.setName("EMP_NAME"); + if (instruction.supressUseDomain) { + BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + dataType.getAdapter(SizedDataTypeAdapter.class).setSize(32); // CHECKSTYLE IGNORE THIS LINE + empEmpName.setDataType(dataType); + } else { + DomainRef ref = factory.newReference(domainName); + empEmpName.setDataType(ref); + } + empEmpName.setLogicalName("従業員名"); + empEmpName.setDefaultValue("no name"); + empEmpName.getAdapter(RepresentationAdapter.class).setRepresentation(true); + tableEmp.getAttributes().add(empEmpName); + + empMgrId = factory.newModel(ColumnModel.class, uuid.get("3d21a85a-72de-41b3-99dd-f4cb94e58d84")); + empMgrId.setName("MGR_ID"); + empMgrId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + empMgrId.setLogicalName("上司ID"); + tableEmp.getAttributes().add(empMgrId); + + empHiredate = factory.newModel(ColumnModel.class, uuid.get("f0b57eed-98ab-4c21-9855-218c592814dc")); + empHiredate.setName("HIREDATE"); + empHiredate.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.DATE)); + tableEmp.getAttributes().add(empHiredate); + + empSal = factory.newModel(ColumnModel.class, uuid.get("80786549-dc2c-4c1c-bcbd-9f6fdec911d2")); + empSal.setName("SAL"); + BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.NUMERIC); + dataType.getAdapter(PrecisionedDataTypeAdapter.class).setPrecision(7); + dataType.getAdapter(PrecisionedDataTypeAdapter.class).setScale(2); + empSal.setDataType(dataType); + tableEmp.getAttributes().add(empSal); + + ColumnCheckConstraint checkConstraint = + factory.newModel(ColumnCheckConstraint.class, uuid.get("873f6660-7a61-4c2c-87a0-e922fa03b88c")); + checkConstraint.setName("positive_sal"); + checkConstraint.setExpression("SAL >= 0"); + empSal.setCheckConstraint(checkConstraint); + + empDeptId = factory.newModel(ColumnModel.class, uuid.get("4ae69b7a-7a0e-422a-89dc-0f0cff77565b")); + empDeptId.setName("DEPT_ID"); + empDeptId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + tableEmp.getAttributes().add(empDeptId); + + empPk = factory.newModel(PrimaryKey.class, uuid.get("6145e6a0-9ff7-4033-999d-99d80392a48f")); + empPk.setName("emp_pkey"); + empPk.getKeyColumns().add(factory.newReference(empId)); + tableEmp.getAttributes().add(empPk); + + Map<UUID, UUID> columnNotNullMap = CollectionsUtil.newHashMap(); + columnNotNullMap.put(empEmpName.getId(), uuid.get("41f178b9-2cb5-4dad-a6c0-48df2d5b1300")); + columnNotNullMap.put(empHiredate.getId(), uuid.get("2d66fd73-8d6b-41d8-b6b8-daec7d6c0c53")); + columnNotNullMap.put(empSal.getId(), uuid.get("a446779a-4fb6-4a0f-8262-22daae856e85")); + columnNotNullMap.put(empDeptId.getId(), uuid.get("b9a0fdce-a965-4118-ae71-5dc7150f6d4e")); + + for (ColumnModel columnModel : Arrays.asList(empEmpName, empHiredate, empSal, empDeptId)) { + NotNullConstraint notNull = + factory.newModel(NotNullConstraint.class, columnNotNullMap.get(columnModel.getId())); + columnModel.setNotNullConstraint(notNull); + } + + empNameIndex = factory.newModel(IndexModel.class, uuid.get("9abc9e01-4cdb-42fe-a495-93b56af35a1d")); + empNameIndex.setName("IDX_EMP_NAME"); + IndexColumnModel indexColumnModel = + factory.newModel(IndexColumnModel.class, uuid.get("52d2b6aa-fff7-4c33-af13-f4d0b63e8e58")); + indexColumnModel.setColumnRef(factory.newReference(empEmpName)); + indexColumnModel.setSortOrder(SortOrder.DESC); + empNameIndex.getIndexColumns().add(indexColumnModel); + tableEmp.getIndexes().add(empNameIndex); + } + + private void createViewHighSal() { + viewHighSal = factory.newModel(ViewModel.class, uuid.get("516f7961-cb7b-48e2-990b-7fb0c750c3a4")); + viewHighSal.setName("V_HIGH_SAL_EMP"); + viewHighSal.setDefinition("SELECT * FROM T_EMP WHERE SAL > 2000;"); + viewHighSal.setLogicalName("高給取り"); + } +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,839 +1,839 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/22 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.jiemamy.Jiemamy; -import org.jiemamy.JiemamyFactory; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.attribute.ColumnModel; -import org.jiemamy.model.attribute.RepresentationAdapter; -import org.jiemamy.model.attribute.constraint.Deferrability; -import org.jiemamy.model.attribute.constraint.ForeignKey; -import org.jiemamy.model.attribute.constraint.NotNullConstraint; -import org.jiemamy.model.attribute.constraint.PrimaryKey; -import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime; -import org.jiemamy.model.attribute.constraint.ForeignKey.ReferentialAction; -import org.jiemamy.model.dataset.DataSetModel; -import org.jiemamy.model.dataset.RecordModel; -import org.jiemamy.model.datatype.BuiltinDataType; -import org.jiemamy.model.datatype.DataTypeCategory; -import org.jiemamy.model.datatype.DomainModel; -import org.jiemamy.model.datatype.DomainRef; -import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; -import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; -import org.jiemamy.model.entity.TableModel; -import org.jiemamy.model.script.Position; - -/** - * Jiemamyテストモデル1(ORDERテーブル)を組み立てるビルダ。 - * - * @author daisuke - */ -public class CoreTestModelBuilder2 extends AbstractTestModelBuilder { - - private static final String ID_1 = "1"; - - private static final String ID_2 = "2"; - - private static final String ID_3 = "3"; - - private static final String ID_4 = "4"; - - // ---- basics - - /** UUID生成戦略 */ - public final UuidStrategy uuid; - - /** 生成方針 */ - public final Instruction instruction; - - /** 生成するモデルのインスタンス空間 */ - public final Jiemamy jiemamy; - - /** 生成に使用するファクトリ */ - public final JiemamyFactory factory; - - /** 生成したモデル */ - public final RootModel rootModel; - - // ---- models - - /** 生成したモデル */ - public DomainModel idDomain; - - /** 生成したモデル */ - public DomainModel nameDomain; - - // item - - /** 生成したモデル */ - public TableModel tableItem; - - /** 生成したモデル */ - public ColumnModel itemId; - - /** 生成したモデル */ - public ColumnModel itemName; - - /** 生成したモデル */ - public ColumnModel itemPrice; - - /** 生成したモデル */ - public PrimaryKey itemPk; - - // user - - /** 生成したモデル */ - public TableModel tableUser; - - /** 生成したモデル */ - public ColumnModel userId; - - /** 生成したモデル */ - public ColumnModel userName; - - /** 生成したモデル */ - public PrimaryKey userPk; - - // order - - /** 生成したモデル */ - public TableModel tableOrder; - - /** 生成したモデル */ - public ColumnModel orderId; - - /** 生成したモデル */ - public ColumnModel orderUserId; - - /** 生成したモデル */ - public ColumnModel orderDate; - - /** 生成したモデル */ - public PrimaryKey orderPk; - - // detail - - /** 生成したモデル */ - public TableModel tableDetail; - - /** 生成したモデル */ - public ColumnModel detailId; - - /** 生成したモデル */ - public ColumnModel detailOrderId; - - /** 生成したモデル */ - public ColumnModel detailItemId; - - /** 生成したモデル */ - public ColumnModel detailQuantity; - - /** 生成したモデル */ - public PrimaryKey detailPk; - - // fk - - /** 生成したモデル */ - public ForeignKey fkDetailItem; - - /** 生成したモデル */ - public ForeignKey fkDetailOrder; - - /** 生成したモデル */ - public ForeignKey fkOrderUser; - - - /** - * インスタンスを生成する。 - */ - public CoreTestModelBuilder2() { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param instruction 設定オブジェクト - */ - public CoreTestModelBuilder2(Instruction instruction) { - this(UuidStrategy.FIXED, instruction, Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param instruction 設定オブジェクト - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder2(Instruction instruction, Jiemamy jiemamy) { - this(UuidStrategy.FIXED, instruction, jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder2(Jiemamy jiemamy) { - this(UuidStrategy.FIXED, new Instruction(), jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - */ - public CoreTestModelBuilder2(UuidStrategy uuid) { - this(uuid, new Instruction(), Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param instruction 設定オブジェクト - */ - public CoreTestModelBuilder2(UuidStrategy uuid, Instruction instruction) { - this(uuid, instruction, Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param instruction 設定オブジェクト - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder2(UuidStrategy uuid, Instruction instruction, Jiemamy jiemamy) { - this.uuid = uuid; - this.instruction = instruction; - this.jiemamy = jiemamy; - factory = jiemamy.getFactory(); - - if (factory.hasRootModel() && uuid == UuidStrategy.FIXED) { - throw new IllegalArgumentException(); - } - rootModel = jiemamy.getFactory().getRootModel(uuid.get("6cbba964-6809-4eb9-936d-ec318012322c")); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder2(UuidStrategy uuid, Jiemamy jiemamy) { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); - } - - public Jiemamy build(String dialectClassName) { - rootModel.setDialectClassName(dialectClassName); - - rootModel.getAroundScript().setScript(Position.BEGIN, "BEGIN;"); - rootModel.getAroundScript().setScript(Position.END, "COMMIT;"); - - rootModel.setDescription("Jiemamyテストモデル2"); - rootModel.setSchemaName("BAR"); - - createDomains(); - createEntities(); - createForeignKeys(); - createDataSets(); - - return jiemamy; - } - - /** - * ビルドしたモデルを持つJiemamyオブジェクトを取得する。 - * - * @return Jiemamyオブジェクト - */ - public Jiemamy getJiemamy() { - return jiemamy; - } - - /** - * データセットを生成する。 - */ - protected void createDataSets() { - if (instruction.supressUseDataSet) { - return; - } - // データセットの生成・追加(1) - DataSetModel dataSetEn = factory.newModel(DataSetModel.class); - dataSetEn.setName("データ群en"); - dataSetEn.getRecords().put(factory.newReference(tableItem), createDataSetEnItem()); - dataSetEn.getRecords().put(factory.newReference(tableUser), createDataSetEnUser()); - dataSetEn.getRecords().put(factory.newReference(tableOrder), createDataSetEnOrder()); - dataSetEn.getRecords().put(factory.newReference(tableDetail), createDataSetEnDetail()); - rootModel.getDataSets().add(dataSetEn); - - // データセットの生成・追加(2) - DataSetModel dataSetJa = factory.newModel(DataSetModel.class); - dataSetJa.setName("データ群ja"); - dataSetJa.getRecords().put(factory.newReference(tableItem), createDataSetJaItem()); - dataSetJa.getRecords().put(factory.newReference(tableUser), createDataSetJaUser()); - dataSetJa.getRecords().put(factory.newReference(tableOrder), createDataSetJaOrder()); - dataSetJa.getRecords().put(factory.newReference(tableDetail), createDataSetJaDetail()); - rootModel.getDataSets().add(dataSetJa); - } - - /** - * ドメインを生成する。 - */ - protected void createDomains() { - if (instruction.supressUseDomain) { - return; - } - - idDomain = factory.newModel(DomainModel.class, uuid.get("9a3ba23c-b328-4c70-a32d-3e4be3ee3f08")); - idDomain.setName("ID"); - idDomain.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - idDomain.setNotNullConstraint(factory.newModel(NotNullConstraint.class)); - if (idDomain.hasAdapter(SerialDataTypeAdapter.class)) { - idDomain.getAdapter(SerialDataTypeAdapter.class).setSerial(true); - } - rootModel.getDomains().add(idDomain); - - nameDomain = factory.newModel(DomainModel.class, uuid.get("e2ebf8a7-90d8-48d4-9b5d-8d2e2601b193")); - nameDomain.setName("NAME"); - BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); - dataType.getAdapter(SizedDataTypeAdapter.class).setSize(32); // CHECKSTYLE IGNORE THIS LINE - nameDomain.setDataType(dataType); - nameDomain.setDescription("人名用の型です。"); - rootModel.getDomains().add(nameDomain); - } - - /** - * エンティティを生成する。 - */ - protected void createEntities() { - createTableItem(); - rootModel.getEntities().add(tableItem); - createTableUser(); - rootModel.getEntities().add(tableUser); - createTableOrder(); - rootModel.getEntities().add(tableOrder); - createTableDetail(); - rootModel.getEntities().add(tableDetail); - } - - /** - * 外部キーを生成する。 - */ - protected void createForeignKeys() { - if (instruction.supressUseForeignKey) { - return; - } - - fkDetailItem = factory.newModel(ForeignKey.class, uuid.get("df781ad0-112a-4db7-a76c-4395b15600b2")); - fkDetailItem.getKeyColumns().add(factory.newReference(detailItemId)); - fkDetailItem.getReferenceColumns().add(factory.newReference(itemId)); - fkDetailItem.setOnDelete(ReferentialAction.RESTRICT); - tableDetail.getAttributes().add(fkDetailItem); - - fkDetailOrder = factory.newModel(ForeignKey.class, uuid.get("fca97c96-db8c-44b4-8427-6207601eaa94")); - fkDetailOrder.getKeyColumns().add(factory.newReference(detailOrderId)); - fkDetailOrder.getReferenceColumns().add(factory.newReference(orderId)); - fkDetailOrder.setOnDelete(ReferentialAction.CASCADE); - Deferrability deferrability = - factory.newModel(Deferrability.class, uuid.get("1726a29c-0984-4042-b2c3-c601671892a1")); - deferrability.setInitiallyCheckTime(InitiallyCheckTime.DEFERRED); - fkDetailOrder.setDeferrability(deferrability); - tableDetail.getAttributes().add(fkDetailOrder); - - fkOrderUser = factory.newModel(ForeignKey.class, uuid.get("325b5aa9-821e-4791-aac5-2d3eb64f9392")); - fkOrderUser.getKeyColumns().add(factory.newReference(orderUserId)); - fkOrderUser.getReferenceColumns().add(factory.newReference(userId)); - fkOrderUser.setOnDelete(ReferentialAction.RESTRICT); - Deferrability deferrability2 = - factory.newModel(Deferrability.class, uuid.get("899f5889-ac30-44dc-b078-35a1b1edc8f0")); - deferrability2.setInitiallyCheckTime(InitiallyCheckTime.IMMEDIATE); - fkOrderUser.setDeferrability(deferrability2); - tableOrder.getAttributes().add(fkOrderUser); - } - - private List<RecordModel> createDataSetEnDetail() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("546244f5-afa2-4e7e-bde0-5a811ced77af")); - ModelUtil.addValue(record, detailId, ID_1); - ModelUtil.addValue(record, detailOrderId, ID_1); - ModelUtil.addValue(record, detailItemId, ID_1); - ModelUtil.addValue(record, detailQuantity, "1"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("943fda94-a3f2-4c47-b19f-9e8655b47362")); - ModelUtil.addValue(record, detailId, ID_2); - ModelUtil.addValue(record, detailOrderId, ID_1); - ModelUtil.addValue(record, detailItemId, ID_4); - ModelUtil.addValue(record, detailQuantity, "3"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("d11db81a-2d53-42b4-9f10-17f98f1f7081")); - ModelUtil.addValue(record, detailId, ID_3); - ModelUtil.addValue(record, detailOrderId, ID_2); - ModelUtil.addValue(record, detailItemId, ID_2); - ModelUtil.addValue(record, detailQuantity, "2"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("0aa0dd6f-5656-4994-abfe-05f05aec7275")); - ModelUtil.addValue(record, detailId, ID_4); - ModelUtil.addValue(record, detailOrderId, ID_2); - ModelUtil.addValue(record, detailItemId, ID_3); - ModelUtil.addValue(record, detailQuantity, "6"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("4b9be90a-886f-47d8-89f0-da03d7ad419e")); - ModelUtil.addValue(record, detailId, "5"); - ModelUtil.addValue(record, detailOrderId, ID_2); - ModelUtil.addValue(record, detailItemId, ID_4); - ModelUtil.addValue(record, detailQuantity, "12"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("23665133-7f4e-4f65-af7c-0de1b655f7c9")); - ModelUtil.addValue(record, detailId, "6"); - ModelUtil.addValue(record, detailOrderId, ID_3); - ModelUtil.addValue(record, detailItemId, ID_2); - ModelUtil.addValue(record, detailQuantity, "1"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetEnItem() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("7162b83a-1815-4b08-8c11-8e6400c05a9e")); - ModelUtil.addValue(record, itemId, ID_1); - ModelUtil.addValue(record, itemName, "DIAMOND"); - ModelUtil.addValue(record, itemPrice, "100000"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("a3d6480d-9088-49d8-a500-872262a635d5")); - ModelUtil.addValue(record, itemId, ID_2); - ModelUtil.addValue(record, itemName, "EMERALD"); - ModelUtil.addValue(record, itemPrice, "75000"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("bf4556ff-fb81-472c-945d-14067945e7c2")); - ModelUtil.addValue(record, itemId, ID_3); - ModelUtil.addValue(record, itemName, "RUBY"); - ModelUtil.addValue(record, itemPrice, "30000"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("fc30dd3e-495d-4f7c-9237-dd9f84c14eb5")); - ModelUtil.addValue(record, itemId, ID_4); - ModelUtil.addValue(record, itemName, "SAPPHIRE"); - ModelUtil.addValue(record, itemPrice, "10000"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetEnOrder() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("bf813157-8690-4eb3-9168-cd4906f13f27")); - ModelUtil.addValue(record, orderId, ID_1); - ModelUtil.addValue(record, orderUserId, ID_2); - ModelUtil.addValue(record, orderDate, "2009-01-23 00:11:22"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("645b241d-a6ba-4821-8682-448f59949b3e")); - ModelUtil.addValue(record, orderId, ID_2); - ModelUtil.addValue(record, orderUserId, ID_3); - ModelUtil.addValue(record, orderDate, "2009-01-23 00:22:33"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("654ceb1b-b6eb-406d-8eac-aa07c7c41e62")); - ModelUtil.addValue(record, orderId, ID_3); - ModelUtil.addValue(record, orderUserId, ID_2); - ModelUtil.addValue(record, orderDate, "2009-01-24 00:33:44"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetEnUser() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("c60fb4ba-e3d6-415e-a22c-20fbaf4e04e6")); - ModelUtil.addValue(record, userId, ID_1); - ModelUtil.addValue(record, userName, "SMITH"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("83d5c923-7c61-4393-8185-ac95042f6476")); - ModelUtil.addValue(record, userId, ID_2); - ModelUtil.addValue(record, userName, "ALLEN"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("2ddd8857-3fca-4020-bb23-49d0126af6fc")); - ModelUtil.addValue(record, userId, ID_3); - ModelUtil.addValue(record, userName, "WARD"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("2b9aeb38-97de-439e-b96b-40a1c82d249e")); - ModelUtil.addValue(record, userId, ID_4); - ModelUtil.addValue(record, userName, "JONES"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("a6242c24a-b415-4a93-867b-16a68c2fe884")); - ModelUtil.addValue(record, userId, "5"); - ModelUtil.addValue(record, userName, "MARTIN"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("3b9d3161-a613-4090-a095-708433b23491")); - ModelUtil.addValue(record, userId, "6"); - ModelUtil.addValue(record, userName, "BLAKE"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("aeaad211-b62e-4a35-b410-d107753469e9")); - ModelUtil.addValue(record, userId, "7"); - ModelUtil.addValue(record, userName, "CLARK"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("8c7c220d-ff7f-48c4-9ce7-1395ed1816fa")); - ModelUtil.addValue(record, userId, "8"); - ModelUtil.addValue(record, userName, "SCOTT"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetJaDetail() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("5a6604ce-6ed2-4542-b009-2a3264b0946a")); - ModelUtil.addValue(record, detailId, ID_1); - ModelUtil.addValue(record, detailOrderId, ID_1); - ModelUtil.addValue(record, detailItemId, ID_1); - ModelUtil.addValue(record, detailQuantity, "1"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("db883c9c-b7d3-44f4-88ba-d9753eeae58a")); - ModelUtil.addValue(record, detailId, ID_2); - ModelUtil.addValue(record, detailOrderId, ID_1); - ModelUtil.addValue(record, detailItemId, ID_4); - ModelUtil.addValue(record, detailQuantity, "3"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("04e92727-483c-42ad-b671-c1e4661c1844")); - ModelUtil.addValue(record, detailId, ID_3); - ModelUtil.addValue(record, detailOrderId, ID_2); - ModelUtil.addValue(record, detailItemId, ID_2); - ModelUtil.addValue(record, detailQuantity, "2"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("f5147476-8bc6-4656-9d0c-fd883a24a18c")); - ModelUtil.addValue(record, detailId, ID_4); - ModelUtil.addValue(record, detailOrderId, ID_2); - ModelUtil.addValue(record, detailItemId, ID_3); - ModelUtil.addValue(record, detailQuantity, "6"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("d849f188-9940-4ecc-98a8-868dac5b3b4e")); - ModelUtil.addValue(record, detailId, "5"); - ModelUtil.addValue(record, detailOrderId, ID_2); - ModelUtil.addValue(record, detailItemId, ID_4); - ModelUtil.addValue(record, detailQuantity, "12"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("2abef8cc-bfb7-4565-ba4e-afca3bf98811")); - ModelUtil.addValue(record, detailId, "6"); - ModelUtil.addValue(record, detailOrderId, ID_3); - ModelUtil.addValue(record, detailItemId, ID_2); - ModelUtil.addValue(record, detailQuantity, "1"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetJaItem() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("5fd803d4-5a05-496b-813e-6399955a79bb")); - ModelUtil.addValue(record, itemId, ID_1); - ModelUtil.addValue(record, itemName, "ダイヤモンド"); - ModelUtil.addValue(record, itemPrice, "100000"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("d59e426b-e5ed-433e-8d5a-e748dc75af60")); - ModelUtil.addValue(record, itemId, ID_2); - ModelUtil.addValue(record, itemName, "エメラルド"); - ModelUtil.addValue(record, itemPrice, "75000"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("59e0a554-162a-4c48-b13d-1dda7fc936e0")); - ModelUtil.addValue(record, itemId, ID_3); - ModelUtil.addValue(record, itemName, "ルビー"); - ModelUtil.addValue(record, itemPrice, "30000"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("1c86858f-1e8b-4fc5-807f-f0548e1811e4")); - ModelUtil.addValue(record, itemId, ID_4); - ModelUtil.addValue(record, itemName, "サファイヤ"); - ModelUtil.addValue(record, itemPrice, "10000"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetJaOrder() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("2bdf3969-c2e5-4e3e-a939-2907ca3a5b6a")); - ModelUtil.addValue(record, orderId, ID_1); - ModelUtil.addValue(record, orderUserId, ID_2); - ModelUtil.addValue(record, orderDate, "2009-01-23 00:11:22"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("cca67c6f-a3b2-4b43-a466-be72ccd66e8f")); - ModelUtil.addValue(record, orderId, ID_2); - ModelUtil.addValue(record, orderUserId, ID_3); - ModelUtil.addValue(record, orderDate, "2009-01-23 00:22:33"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("1f74ab8a-3191-464b-89c3-f4f3dddb8ce8")); - ModelUtil.addValue(record, orderId, ID_2); - ModelUtil.addValue(record, orderUserId, ID_2); - ModelUtil.addValue(record, orderDate, "2009-01-24 00:33:44"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetJaUser() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("25288a67-b4c7-4296-8113-835afeb15c9d")); - ModelUtil.addValue(record, userId, ID_1); - ModelUtil.addValue(record, userName, "鈴木 茂"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("20a62610-ad04-479f-85c6-a1340e26adb5")); - ModelUtil.addValue(record, userId, ID_2); - ModelUtil.addValue(record, userName, "内海 透"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("d8fa5455-9791-46fc-9695-da7a5167f7ea")); - ModelUtil.addValue(record, userId, ID_3); - ModelUtil.addValue(record, userName, "村瀬 武彦"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("3cc66837-d604-4af8-af01-343924e9f058")); - ModelUtil.addValue(record, userId, ID_4); - ModelUtil.addValue(record, userName, "近藤 美樹"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("2f09b9fe-78fd-4f8a-abf2-f077040f45f2")); - ModelUtil.addValue(record, userId, "5"); - ModelUtil.addValue(record, userName, "榊 美子"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("e3431be3-462c-4419-a2a0-e821597490cc")); - ModelUtil.addValue(record, userId, "6"); - ModelUtil.addValue(record, userName, "三浦 佑"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("c50a3e24-dd00-4969-aae9-69cf9be7f035")); - ModelUtil.addValue(record, userId, "7"); - ModelUtil.addValue(record, userName, "前島 孝幸"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("890bf55f-8bfd-420c-a9df-801da73bc46d")); - ModelUtil.addValue(record, userId, "8"); - ModelUtil.addValue(record, userName, "島崎 由比"); - result.add(record); - - return result; - } - - private void createTableDetail() { - tableDetail = factory.newModel(TableModel.class, uuid.get("5705ed1a-f329-4f21-9956-94caf4863fba")); - tableDetail.setName("T_DETAIL"); - tableDetail.setLogicalName("明細"); - tableDetail.setDescription("明細テーブルです。"); - - detailId = factory.newModel(ColumnModel.class, uuid.get("d3571020-4e1b-4158-958d-b5460fa6c32c")); - detailId.setName("ID"); - if (instruction.supressUseDomain) { - detailId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - } else { - DomainRef ref = factory.newReference(idDomain); - detailId.setDataType(ref); - } - detailId.setLogicalName("ユーザID"); - tableDetail.getAttributes().add(detailId); - - detailOrderId = factory.newModel(ColumnModel.class, uuid.get("a28c64c6-b379-41a4-9563-b774f5bce165")); - detailOrderId.setName("ORDER_ID"); - detailOrderId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - tableDetail.getAttributes().add(detailOrderId); - - detailItemId = factory.newModel(ColumnModel.class, uuid.get("b4d50786-3b3e-4557-baa3-b739159f0530")); - detailItemId.setName("ITEM_ID"); - detailItemId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - tableDetail.getAttributes().add(detailItemId); - - detailQuantity = factory.newModel(ColumnModel.class, uuid.get("77bb21f4-e793-4198-a695-42363dac2216")); - detailQuantity.setName("QUANTITY"); - detailQuantity.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - tableDetail.getAttributes().add(detailQuantity); - - detailPk = factory.newModel(PrimaryKey.class, uuid.get("90243681-19af-4bc0-9e6f-f814fbc58f85")); - detailPk.getKeyColumns().add(factory.newReference(detailId)); - tableDetail.getAttributes().add(detailPk); - - for (ColumnModel columnModel : Arrays.asList(detailOrderId, detailItemId, detailQuantity)) { - NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); - columnModel.setNotNullConstraint(notNull); - } - } - - private void createTableItem() { - tableItem = factory.newModel(TableModel.class, uuid.get("7ecf5ba1-e80c-472c-b19b-bef2649d7974")); - tableItem.setName("T_ITEM"); - - tableItem.getAroundScript().setScript(Position.BEGIN, "/* test begin script of T_ITEM */"); - tableItem.getAroundScript().setScript(Position.END, "/* test end script of T_ITEM */"); - - tableItem.setDescription("商品マスタです。"); - - itemId = factory.newModel(ColumnModel.class, uuid.get("5a9585be-4b0d-4675-99aa-97b0417c816c")); - itemId.setName("ID"); - if (instruction.supressUseDomain) { - itemId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - } else { - DomainRef ref = factory.newReference(idDomain); - itemId.setDataType(ref); - } - itemId.setLogicalName("商品ID"); - tableItem.getAttributes().add(itemId); - - itemName = factory.newModel(ColumnModel.class, uuid.get("5c9b38e1-2cc9-45f9-ad3f-20b02471cc40")); - itemName.setName("NAME"); - BuiltinDataType itemNameDataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); - itemNameDataType.getAdapter(SizedDataTypeAdapter.class).setSize(20); - itemName.setDataType(itemNameDataType); - itemName.setLogicalName("商品名"); - itemName.getAdapter(RepresentationAdapter.class).setRepresentation(true); - tableItem.getAttributes().add(itemName); - - itemPrice = factory.newModel(ColumnModel.class, uuid.get("7a0cabe3-d382-4e5d-845b-dadd1b637a5f")); - itemPrice.setName("PRICE"); - BuiltinDataType itemPriceDataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); - itemPriceDataType.getAdapter(SizedDataTypeAdapter.class).setSize(20); - itemPrice.setDataType(itemPriceDataType); - itemPrice.setLogicalName("価格"); - tableItem.getAttributes().add(itemPrice); - - itemPk = factory.newModel(PrimaryKey.class, uuid.get("32b2b2f3-e668-404b-9478-56f1e680f915")); - itemPk.getKeyColumns().add(factory.newReference(itemId)); - tableItem.getAttributes().add(itemPk); - - for (ColumnModel columnModel : Arrays.asList(itemName, itemPrice)) { - NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); - columnModel.setNotNullConstraint(notNull); - } - } - - private void createTableOrder() { - tableOrder = factory.newModel(TableModel.class, uuid.get("cefee0d9-d23f-441b-986a-66660354ec74")); - tableOrder.setName("T_ORDER"); - tableOrder.setLogicalName("注文"); - tableOrder.setDescription("注文テーブルです。"); - - orderId = factory.newModel(ColumnModel.class, uuid.get("b647212a-4d8f-4d18-88e4-5397e54ebe67")); - orderId.setName("ID"); - if (instruction.supressUseDomain) { - orderId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - } else { - DomainRef ref = factory.newReference(idDomain); - orderId.setDataType(ref); - } - orderId.setLogicalName("注文ID"); - tableOrder.getAttributes().add(orderId); - - orderUserId = factory.newModel(ColumnModel.class, uuid.get("db7a2f62-9658-406a-9dc1-8b90ae2da47c")); - orderUserId.setName("USER_ID"); - orderUserId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - orderUserId.setLogicalName("オーダーユーザID"); - tableOrder.getAttributes().add(orderUserId); - - orderDate = factory.newModel(ColumnModel.class, uuid.get("4ce761b0-137b-4105-ad2a-2efcba5e6bc4")); - orderDate.setName("ORDER_DATE"); - orderDate.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.TIMESTAMP)); - tableOrder.getAttributes().add(orderDate); - - orderPk = factory.newModel(PrimaryKey.class, uuid.get("b204ff42-537b-4e14-bf61-e9baf1b119dc")); - orderPk.getKeyColumns().add(factory.newReference(orderId)); - tableOrder.getAttributes().add(orderPk); - - for (ColumnModel columnModel : Arrays.asList(orderUserId, orderDate)) { - NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); - columnModel.setNotNullConstraint(notNull); - } - } - - private void createTableUser() { - tableUser = factory.newModel(TableModel.class, uuid.get("0802ef7b-b2da-4fc4-8104-0c99a1e472d5")); - tableUser.setName("T_USER"); - tableUser.setLogicalName("ユーザ"); - tableUser.setDescription("ユーザマスタです。"); - - userId = factory.newModel(ColumnModel.class, uuid.get("6b022a79-45a6-4be4-9d3d-cfb27042a08e")); - userId.setName("ID"); - if (instruction.supressUseDomain) { - userId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); - } else { - DomainRef ref = factory.newReference(idDomain); - userId.setDataType(ref); - } - userId.setLogicalName("ユーザID"); - tableUser.getAttributes().add(userId); - - userName = factory.newModel(ColumnModel.class, uuid.get("dacc68d2-fe32-4f4b-8082-9d55232ba7da")); - userName.setName("NAME"); - if (instruction.supressUseDomain) { - BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); - dataType.getAdapter(SizedDataTypeAdapter.class).setSize(32); // CHECKSTYLE IGNORE THIS LINE - userName.setDataType(dataType); - } else { - DomainRef ref = factory.newReference(nameDomain); - userName.setDataType(ref); - } - userName.setLogicalName("ユーザ名"); - userName.setDefaultValue("no name"); - userName.getAdapter(RepresentationAdapter.class).setRepresentation(true); - tableUser.getAttributes().add(userName); - - userPk = factory.newModel(PrimaryKey.class, uuid.get("dac295e3-c390-46ee-9a5b-e89636ab9d7e")); - userPk.getKeyColumns().add(factory.newReference(userId)); - tableUser.getAttributes().add(userPk); - - NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); - userName.setNotNullConstraint(notNull); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/22 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.jiemamy.Jiemamy; +import org.jiemamy.JiemamyFactory; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.RepresentationAdapter; +import org.jiemamy.model.attribute.constraint.Deferrability; +import org.jiemamy.model.attribute.constraint.ForeignKey; +import org.jiemamy.model.attribute.constraint.NotNullConstraint; +import org.jiemamy.model.attribute.constraint.PrimaryKey; +import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime; +import org.jiemamy.model.attribute.constraint.ForeignKey.ReferentialAction; +import org.jiemamy.model.dataset.DataSetModel; +import org.jiemamy.model.dataset.RecordModel; +import org.jiemamy.model.datatype.BuiltinDataType; +import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.datatype.DomainRef; +import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.script.Position; + +/** + * Jiemamyテストモデル1(ORDERテーブル)を組み立てるビルダ。 + * + * @author daisuke + */ +public class CoreTestModelBuilder2 extends AbstractTestModelBuilder { + + private static final String ID_1 = "1"; + + private static final String ID_2 = "2"; + + private static final String ID_3 = "3"; + + private static final String ID_4 = "4"; + + // ---- basics + + /** UUID生成戦略 */ + public final UuidStrategy uuid; + + /** 生成方針 */ + public final Instruction instruction; + + /** 生成するモデルのインスタンス空間 */ + public final Jiemamy jiemamy; + + /** 生成に使用するファクトリ */ + public final JiemamyFactory factory; + + /** 生成したモデル */ + public final RootModel rootModel; + + // ---- models + + /** 生成したモデル */ + public DomainModel idDomain; + + /** 生成したモデル */ + public DomainModel nameDomain; + + // item + + /** 生成したモデル */ + public TableModel tableItem; + + /** 生成したモデル */ + public ColumnModel itemId; + + /** 生成したモデル */ + public ColumnModel itemName; + + /** 生成したモデル */ + public ColumnModel itemPrice; + + /** 生成したモデル */ + public PrimaryKey itemPk; + + // user + + /** 生成したモデル */ + public TableModel tableUser; + + /** 生成したモデル */ + public ColumnModel userId; + + /** 生成したモデル */ + public ColumnModel userName; + + /** 生成したモデル */ + public PrimaryKey userPk; + + // order + + /** 生成したモデル */ + public TableModel tableOrder; + + /** 生成したモデル */ + public ColumnModel orderId; + + /** 生成したモデル */ + public ColumnModel orderUserId; + + /** 生成したモデル */ + public ColumnModel orderDate; + + /** 生成したモデル */ + public PrimaryKey orderPk; + + // detail + + /** 生成したモデル */ + public TableModel tableDetail; + + /** 生成したモデル */ + public ColumnModel detailId; + + /** 生成したモデル */ + public ColumnModel detailOrderId; + + /** 生成したモデル */ + public ColumnModel detailItemId; + + /** 生成したモデル */ + public ColumnModel detailQuantity; + + /** 生成したモデル */ + public PrimaryKey detailPk; + + // fk + + /** 生成したモデル */ + public ForeignKey fkDetailItem; + + /** 生成したモデル */ + public ForeignKey fkDetailOrder; + + /** 生成したモデル */ + public ForeignKey fkOrderUser; + + + /** + * インスタンスを生成する。 + */ + public CoreTestModelBuilder2() { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param instruction 設定オブジェクト + */ + public CoreTestModelBuilder2(Instruction instruction) { + this(UuidStrategy.FIXED, instruction, Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param instruction 設定オブジェクト + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder2(Instruction instruction, Jiemamy jiemamy) { + this(UuidStrategy.FIXED, instruction, jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder2(Jiemamy jiemamy) { + this(UuidStrategy.FIXED, new Instruction(), jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + */ + public CoreTestModelBuilder2(UuidStrategy uuid) { + this(uuid, new Instruction(), Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param instruction 設定オブジェクト + */ + public CoreTestModelBuilder2(UuidStrategy uuid, Instruction instruction) { + this(uuid, instruction, Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param instruction 設定オブジェクト + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder2(UuidStrategy uuid, Instruction instruction, Jiemamy jiemamy) { + this.uuid = uuid; + this.instruction = instruction; + this.jiemamy = jiemamy; + factory = jiemamy.getFactory(); + + if (factory.hasRootModel() && uuid == UuidStrategy.FIXED) { + throw new IllegalArgumentException(); + } + rootModel = jiemamy.getFactory().getRootModel(uuid.get("6cbba964-6809-4eb9-936d-ec318012322c")); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder2(UuidStrategy uuid, Jiemamy jiemamy) { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); + } + + public Jiemamy build(String dialectClassName) { + rootModel.setDialectClassName(dialectClassName); + + rootModel.getAroundScript().setScript(Position.BEGIN, "BEGIN;"); + rootModel.getAroundScript().setScript(Position.END, "COMMIT;"); + + rootModel.setDescription("Jiemamyテストモデル2"); + rootModel.setSchemaName("BAR"); + + createDomains(); + createEntities(); + createForeignKeys(); + createDataSets(); + + return jiemamy; + } + + /** + * ビルドしたモデルを持つJiemamyオブジェクトを取得する。 + * + * @return Jiemamyオブジェクト + */ + public Jiemamy getJiemamy() { + return jiemamy; + } + + /** + * データセットを生成する。 + */ + protected void createDataSets() { + if (instruction.supressUseDataSet) { + return; + } + // データセットの生成・追加(1) + DataSetModel dataSetEn = factory.newModel(DataSetModel.class); + dataSetEn.setName("データ群en"); + dataSetEn.getRecords().put(factory.newReference(tableItem), createDataSetEnItem()); + dataSetEn.getRecords().put(factory.newReference(tableUser), createDataSetEnUser()); + dataSetEn.getRecords().put(factory.newReference(tableOrder), createDataSetEnOrder()); + dataSetEn.getRecords().put(factory.newReference(tableDetail), createDataSetEnDetail()); + rootModel.getDataSets().add(dataSetEn); + + // データセットの生成・追加(2) + DataSetModel dataSetJa = factory.newModel(DataSetModel.class); + dataSetJa.setName("データ群ja"); + dataSetJa.getRecords().put(factory.newReference(tableItem), createDataSetJaItem()); + dataSetJa.getRecords().put(factory.newReference(tableUser), createDataSetJaUser()); + dataSetJa.getRecords().put(factory.newReference(tableOrder), createDataSetJaOrder()); + dataSetJa.getRecords().put(factory.newReference(tableDetail), createDataSetJaDetail()); + rootModel.getDataSets().add(dataSetJa); + } + + /** + * ドメインを生成する。 + */ + protected void createDomains() { + if (instruction.supressUseDomain) { + return; + } + + idDomain = factory.newModel(DomainModel.class, uuid.get("9a3ba23c-b328-4c70-a32d-3e4be3ee3f08")); + idDomain.setName("ID"); + idDomain.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + idDomain.setNotNullConstraint(factory.newModel(NotNullConstraint.class)); + if (idDomain.hasAdapter(SerialDataTypeAdapter.class)) { + idDomain.getAdapter(SerialDataTypeAdapter.class).setSerial(true); + } + rootModel.getDomains().add(idDomain); + + nameDomain = factory.newModel(DomainModel.class, uuid.get("e2ebf8a7-90d8-48d4-9b5d-8d2e2601b193")); + nameDomain.setName("NAME"); + BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + dataType.getAdapter(SizedDataTypeAdapter.class).setSize(32); // CHECKSTYLE IGNORE THIS LINE + nameDomain.setDataType(dataType); + nameDomain.setDescription("人名用の型です。"); + rootModel.getDomains().add(nameDomain); + } + + /** + * エンティティを生成する。 + */ + protected void createEntities() { + createTableItem(); + rootModel.getEntities().add(tableItem); + createTableUser(); + rootModel.getEntities().add(tableUser); + createTableOrder(); + rootModel.getEntities().add(tableOrder); + createTableDetail(); + rootModel.getEntities().add(tableDetail); + } + + /** + * 外部キーを生成する。 + */ + protected void createForeignKeys() { + if (instruction.supressUseForeignKey) { + return; + } + + fkDetailItem = factory.newModel(ForeignKey.class, uuid.get("df781ad0-112a-4db7-a76c-4395b15600b2")); + fkDetailItem.getKeyColumns().add(factory.newReference(detailItemId)); + fkDetailItem.getReferenceColumns().add(factory.newReference(itemId)); + fkDetailItem.setOnDelete(ReferentialAction.RESTRICT); + tableDetail.getAttributes().add(fkDetailItem); + + fkDetailOrder = factory.newModel(ForeignKey.class, uuid.get("fca97c96-db8c-44b4-8427-6207601eaa94")); + fkDetailOrder.getKeyColumns().add(factory.newReference(detailOrderId)); + fkDetailOrder.getReferenceColumns().add(factory.newReference(orderId)); + fkDetailOrder.setOnDelete(ReferentialAction.CASCADE); + Deferrability deferrability = + factory.newModel(Deferrability.class, uuid.get("1726a29c-0984-4042-b2c3-c601671892a1")); + deferrability.setInitiallyCheckTime(InitiallyCheckTime.DEFERRED); + fkDetailOrder.setDeferrability(deferrability); + tableDetail.getAttributes().add(fkDetailOrder); + + fkOrderUser = factory.newModel(ForeignKey.class, uuid.get("325b5aa9-821e-4791-aac5-2d3eb64f9392")); + fkOrderUser.getKeyColumns().add(factory.newReference(orderUserId)); + fkOrderUser.getReferenceColumns().add(factory.newReference(userId)); + fkOrderUser.setOnDelete(ReferentialAction.RESTRICT); + Deferrability deferrability2 = + factory.newModel(Deferrability.class, uuid.get("899f5889-ac30-44dc-b078-35a1b1edc8f0")); + deferrability2.setInitiallyCheckTime(InitiallyCheckTime.IMMEDIATE); + fkOrderUser.setDeferrability(deferrability2); + tableOrder.getAttributes().add(fkOrderUser); + } + + private List<RecordModel> createDataSetEnDetail() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("546244f5-afa2-4e7e-bde0-5a811ced77af")); + ModelUtil.addValue(record, detailId, ID_1); + ModelUtil.addValue(record, detailOrderId, ID_1); + ModelUtil.addValue(record, detailItemId, ID_1); + ModelUtil.addValue(record, detailQuantity, "1"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("943fda94-a3f2-4c47-b19f-9e8655b47362")); + ModelUtil.addValue(record, detailId, ID_2); + ModelUtil.addValue(record, detailOrderId, ID_1); + ModelUtil.addValue(record, detailItemId, ID_4); + ModelUtil.addValue(record, detailQuantity, "3"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("d11db81a-2d53-42b4-9f10-17f98f1f7081")); + ModelUtil.addValue(record, detailId, ID_3); + ModelUtil.addValue(record, detailOrderId, ID_2); + ModelUtil.addValue(record, detailItemId, ID_2); + ModelUtil.addValue(record, detailQuantity, "2"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("0aa0dd6f-5656-4994-abfe-05f05aec7275")); + ModelUtil.addValue(record, detailId, ID_4); + ModelUtil.addValue(record, detailOrderId, ID_2); + ModelUtil.addValue(record, detailItemId, ID_3); + ModelUtil.addValue(record, detailQuantity, "6"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("4b9be90a-886f-47d8-89f0-da03d7ad419e")); + ModelUtil.addValue(record, detailId, "5"); + ModelUtil.addValue(record, detailOrderId, ID_2); + ModelUtil.addValue(record, detailItemId, ID_4); + ModelUtil.addValue(record, detailQuantity, "12"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("23665133-7f4e-4f65-af7c-0de1b655f7c9")); + ModelUtil.addValue(record, detailId, "6"); + ModelUtil.addValue(record, detailOrderId, ID_3); + ModelUtil.addValue(record, detailItemId, ID_2); + ModelUtil.addValue(record, detailQuantity, "1"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetEnItem() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("7162b83a-1815-4b08-8c11-8e6400c05a9e")); + ModelUtil.addValue(record, itemId, ID_1); + ModelUtil.addValue(record, itemName, "DIAMOND"); + ModelUtil.addValue(record, itemPrice, "100000"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("a3d6480d-9088-49d8-a500-872262a635d5")); + ModelUtil.addValue(record, itemId, ID_2); + ModelUtil.addValue(record, itemName, "EMERALD"); + ModelUtil.addValue(record, itemPrice, "75000"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("bf4556ff-fb81-472c-945d-14067945e7c2")); + ModelUtil.addValue(record, itemId, ID_3); + ModelUtil.addValue(record, itemName, "RUBY"); + ModelUtil.addValue(record, itemPrice, "30000"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("fc30dd3e-495d-4f7c-9237-dd9f84c14eb5")); + ModelUtil.addValue(record, itemId, ID_4); + ModelUtil.addValue(record, itemName, "SAPPHIRE"); + ModelUtil.addValue(record, itemPrice, "10000"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetEnOrder() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("bf813157-8690-4eb3-9168-cd4906f13f27")); + ModelUtil.addValue(record, orderId, ID_1); + ModelUtil.addValue(record, orderUserId, ID_2); + ModelUtil.addValue(record, orderDate, "2009-01-23 00:11:22"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("645b241d-a6ba-4821-8682-448f59949b3e")); + ModelUtil.addValue(record, orderId, ID_2); + ModelUtil.addValue(record, orderUserId, ID_3); + ModelUtil.addValue(record, orderDate, "2009-01-23 00:22:33"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("654ceb1b-b6eb-406d-8eac-aa07c7c41e62")); + ModelUtil.addValue(record, orderId, ID_3); + ModelUtil.addValue(record, orderUserId, ID_2); + ModelUtil.addValue(record, orderDate, "2009-01-24 00:33:44"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetEnUser() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("c60fb4ba-e3d6-415e-a22c-20fbaf4e04e6")); + ModelUtil.addValue(record, userId, ID_1); + ModelUtil.addValue(record, userName, "SMITH"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("83d5c923-7c61-4393-8185-ac95042f6476")); + ModelUtil.addValue(record, userId, ID_2); + ModelUtil.addValue(record, userName, "ALLEN"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("2ddd8857-3fca-4020-bb23-49d0126af6fc")); + ModelUtil.addValue(record, userId, ID_3); + ModelUtil.addValue(record, userName, "WARD"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("2b9aeb38-97de-439e-b96b-40a1c82d249e")); + ModelUtil.addValue(record, userId, ID_4); + ModelUtil.addValue(record, userName, "JONES"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("a6242c24a-b415-4a93-867b-16a68c2fe884")); + ModelUtil.addValue(record, userId, "5"); + ModelUtil.addValue(record, userName, "MARTIN"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("3b9d3161-a613-4090-a095-708433b23491")); + ModelUtil.addValue(record, userId, "6"); + ModelUtil.addValue(record, userName, "BLAKE"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("aeaad211-b62e-4a35-b410-d107753469e9")); + ModelUtil.addValue(record, userId, "7"); + ModelUtil.addValue(record, userName, "CLARK"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("8c7c220d-ff7f-48c4-9ce7-1395ed1816fa")); + ModelUtil.addValue(record, userId, "8"); + ModelUtil.addValue(record, userName, "SCOTT"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetJaDetail() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("5a6604ce-6ed2-4542-b009-2a3264b0946a")); + ModelUtil.addValue(record, detailId, ID_1); + ModelUtil.addValue(record, detailOrderId, ID_1); + ModelUtil.addValue(record, detailItemId, ID_1); + ModelUtil.addValue(record, detailQuantity, "1"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("db883c9c-b7d3-44f4-88ba-d9753eeae58a")); + ModelUtil.addValue(record, detailId, ID_2); + ModelUtil.addValue(record, detailOrderId, ID_1); + ModelUtil.addValue(record, detailItemId, ID_4); + ModelUtil.addValue(record, detailQuantity, "3"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("04e92727-483c-42ad-b671-c1e4661c1844")); + ModelUtil.addValue(record, detailId, ID_3); + ModelUtil.addValue(record, detailOrderId, ID_2); + ModelUtil.addValue(record, detailItemId, ID_2); + ModelUtil.addValue(record, detailQuantity, "2"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("f5147476-8bc6-4656-9d0c-fd883a24a18c")); + ModelUtil.addValue(record, detailId, ID_4); + ModelUtil.addValue(record, detailOrderId, ID_2); + ModelUtil.addValue(record, detailItemId, ID_3); + ModelUtil.addValue(record, detailQuantity, "6"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("d849f188-9940-4ecc-98a8-868dac5b3b4e")); + ModelUtil.addValue(record, detailId, "5"); + ModelUtil.addValue(record, detailOrderId, ID_2); + ModelUtil.addValue(record, detailItemId, ID_4); + ModelUtil.addValue(record, detailQuantity, "12"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("2abef8cc-bfb7-4565-ba4e-afca3bf98811")); + ModelUtil.addValue(record, detailId, "6"); + ModelUtil.addValue(record, detailOrderId, ID_3); + ModelUtil.addValue(record, detailItemId, ID_2); + ModelUtil.addValue(record, detailQuantity, "1"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetJaItem() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("5fd803d4-5a05-496b-813e-6399955a79bb")); + ModelUtil.addValue(record, itemId, ID_1); + ModelUtil.addValue(record, itemName, "ダイヤモンド"); + ModelUtil.addValue(record, itemPrice, "100000"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("d59e426b-e5ed-433e-8d5a-e748dc75af60")); + ModelUtil.addValue(record, itemId, ID_2); + ModelUtil.addValue(record, itemName, "エメラルド"); + ModelUtil.addValue(record, itemPrice, "75000"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("59e0a554-162a-4c48-b13d-1dda7fc936e0")); + ModelUtil.addValue(record, itemId, ID_3); + ModelUtil.addValue(record, itemName, "ルビー"); + ModelUtil.addValue(record, itemPrice, "30000"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("1c86858f-1e8b-4fc5-807f-f0548e1811e4")); + ModelUtil.addValue(record, itemId, ID_4); + ModelUtil.addValue(record, itemName, "サファイヤ"); + ModelUtil.addValue(record, itemPrice, "10000"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetJaOrder() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("2bdf3969-c2e5-4e3e-a939-2907ca3a5b6a")); + ModelUtil.addValue(record, orderId, ID_1); + ModelUtil.addValue(record, orderUserId, ID_2); + ModelUtil.addValue(record, orderDate, "2009-01-23 00:11:22"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("cca67c6f-a3b2-4b43-a466-be72ccd66e8f")); + ModelUtil.addValue(record, orderId, ID_2); + ModelUtil.addValue(record, orderUserId, ID_3); + ModelUtil.addValue(record, orderDate, "2009-01-23 00:22:33"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("1f74ab8a-3191-464b-89c3-f4f3dddb8ce8")); + ModelUtil.addValue(record, orderId, ID_2); + ModelUtil.addValue(record, orderUserId, ID_2); + ModelUtil.addValue(record, orderDate, "2009-01-24 00:33:44"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetJaUser() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("25288a67-b4c7-4296-8113-835afeb15c9d")); + ModelUtil.addValue(record, userId, ID_1); + ModelUtil.addValue(record, userName, "鈴木 茂"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("20a62610-ad04-479f-85c6-a1340e26adb5")); + ModelUtil.addValue(record, userId, ID_2); + ModelUtil.addValue(record, userName, "内海 透"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("d8fa5455-9791-46fc-9695-da7a5167f7ea")); + ModelUtil.addValue(record, userId, ID_3); + ModelUtil.addValue(record, userName, "村瀬 武彦"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("3cc66837-d604-4af8-af01-343924e9f058")); + ModelUtil.addValue(record, userId, ID_4); + ModelUtil.addValue(record, userName, "近藤 美樹"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("2f09b9fe-78fd-4f8a-abf2-f077040f45f2")); + ModelUtil.addValue(record, userId, "5"); + ModelUtil.addValue(record, userName, "榊 美子"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("e3431be3-462c-4419-a2a0-e821597490cc")); + ModelUtil.addValue(record, userId, "6"); + ModelUtil.addValue(record, userName, "三浦 佑"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("c50a3e24-dd00-4969-aae9-69cf9be7f035")); + ModelUtil.addValue(record, userId, "7"); + ModelUtil.addValue(record, userName, "前島 孝幸"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("890bf55f-8bfd-420c-a9df-801da73bc46d")); + ModelUtil.addValue(record, userId, "8"); + ModelUtil.addValue(record, userName, "島崎 由比"); + result.add(record); + + return result; + } + + private void createTableDetail() { + tableDetail = factory.newModel(TableModel.class, uuid.get("5705ed1a-f329-4f21-9956-94caf4863fba")); + tableDetail.setName("T_DETAIL"); + tableDetail.setLogicalName("明細"); + tableDetail.setDescription("明細テーブルです。"); + + detailId = factory.newModel(ColumnModel.class, uuid.get("d3571020-4e1b-4158-958d-b5460fa6c32c")); + detailId.setName("ID"); + if (instruction.supressUseDomain) { + detailId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + } else { + DomainRef ref = factory.newReference(idDomain); + detailId.setDataType(ref); + } + detailId.setLogicalName("ユーザID"); + tableDetail.getAttributes().add(detailId); + + detailOrderId = factory.newModel(ColumnModel.class, uuid.get("a28c64c6-b379-41a4-9563-b774f5bce165")); + detailOrderId.setName("ORDER_ID"); + detailOrderId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + tableDetail.getAttributes().add(detailOrderId); + + detailItemId = factory.newModel(ColumnModel.class, uuid.get("b4d50786-3b3e-4557-baa3-b739159f0530")); + detailItemId.setName("ITEM_ID"); + detailItemId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + tableDetail.getAttributes().add(detailItemId); + + detailQuantity = factory.newModel(ColumnModel.class, uuid.get("77bb21f4-e793-4198-a695-42363dac2216")); + detailQuantity.setName("QUANTITY"); + detailQuantity.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + tableDetail.getAttributes().add(detailQuantity); + + detailPk = factory.newModel(PrimaryKey.class, uuid.get("90243681-19af-4bc0-9e6f-f814fbc58f85")); + detailPk.getKeyColumns().add(factory.newReference(detailId)); + tableDetail.getAttributes().add(detailPk); + + for (ColumnModel columnModel : Arrays.asList(detailOrderId, detailItemId, detailQuantity)) { + NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); + columnModel.setNotNullConstraint(notNull); + } + } + + private void createTableItem() { + tableItem = factory.newModel(TableModel.class, uuid.get("7ecf5ba1-e80c-472c-b19b-bef2649d7974")); + tableItem.setName("T_ITEM"); + + tableItem.getAroundScript().setScript(Position.BEGIN, "/* test begin script of T_ITEM */"); + tableItem.getAroundScript().setScript(Position.END, "/* test end script of T_ITEM */"); + + tableItem.setDescription("商品マスタです。"); + + itemId = factory.newModel(ColumnModel.class, uuid.get("5a9585be-4b0d-4675-99aa-97b0417c816c")); + itemId.setName("ID"); + if (instruction.supressUseDomain) { + itemId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + } else { + DomainRef ref = factory.newReference(idDomain); + itemId.setDataType(ref); + } + itemId.setLogicalName("商品ID"); + tableItem.getAttributes().add(itemId); + + itemName = factory.newModel(ColumnModel.class, uuid.get("5c9b38e1-2cc9-45f9-ad3f-20b02471cc40")); + itemName.setName("NAME"); + BuiltinDataType itemNameDataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + itemNameDataType.getAdapter(SizedDataTypeAdapter.class).setSize(20); + itemName.setDataType(itemNameDataType); + itemName.setLogicalName("商品名"); + itemName.getAdapter(RepresentationAdapter.class).setRepresentation(true); + tableItem.getAttributes().add(itemName); + + itemPrice = factory.newModel(ColumnModel.class, uuid.get("7a0cabe3-d382-4e5d-845b-dadd1b637a5f")); + itemPrice.setName("PRICE"); + BuiltinDataType itemPriceDataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + itemPriceDataType.getAdapter(SizedDataTypeAdapter.class).setSize(20); + itemPrice.setDataType(itemPriceDataType); + itemPrice.setLogicalName("価格"); + tableItem.getAttributes().add(itemPrice); + + itemPk = factory.newModel(PrimaryKey.class, uuid.get("32b2b2f3-e668-404b-9478-56f1e680f915")); + itemPk.getKeyColumns().add(factory.newReference(itemId)); + tableItem.getAttributes().add(itemPk); + + for (ColumnModel columnModel : Arrays.asList(itemName, itemPrice)) { + NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); + columnModel.setNotNullConstraint(notNull); + } + } + + private void createTableOrder() { + tableOrder = factory.newModel(TableModel.class, uuid.get("cefee0d9-d23f-441b-986a-66660354ec74")); + tableOrder.setName("T_ORDER"); + tableOrder.setLogicalName("注文"); + tableOrder.setDescription("注文テーブルです。"); + + orderId = factory.newModel(ColumnModel.class, uuid.get("b647212a-4d8f-4d18-88e4-5397e54ebe67")); + orderId.setName("ID"); + if (instruction.supressUseDomain) { + orderId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + } else { + DomainRef ref = factory.newReference(idDomain); + orderId.setDataType(ref); + } + orderId.setLogicalName("注文ID"); + tableOrder.getAttributes().add(orderId); + + orderUserId = factory.newModel(ColumnModel.class, uuid.get("db7a2f62-9658-406a-9dc1-8b90ae2da47c")); + orderUserId.setName("USER_ID"); + orderUserId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + orderUserId.setLogicalName("オーダーユーザID"); + tableOrder.getAttributes().add(orderUserId); + + orderDate = factory.newModel(ColumnModel.class, uuid.get("4ce761b0-137b-4105-ad2a-2efcba5e6bc4")); + orderDate.setName("ORDER_DATE"); + orderDate.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.TIMESTAMP)); + tableOrder.getAttributes().add(orderDate); + + orderPk = factory.newModel(PrimaryKey.class, uuid.get("b204ff42-537b-4e14-bf61-e9baf1b119dc")); + orderPk.getKeyColumns().add(factory.newReference(orderId)); + tableOrder.getAttributes().add(orderPk); + + for (ColumnModel columnModel : Arrays.asList(orderUserId, orderDate)) { + NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); + columnModel.setNotNullConstraint(notNull); + } + } + + private void createTableUser() { + tableUser = factory.newModel(TableModel.class, uuid.get("0802ef7b-b2da-4fc4-8104-0c99a1e472d5")); + tableUser.setName("T_USER"); + tableUser.setLogicalName("ユーザ"); + tableUser.setDescription("ユーザマスタです。"); + + userId = factory.newModel(ColumnModel.class, uuid.get("6b022a79-45a6-4be4-9d3d-cfb27042a08e")); + userId.setName("ID"); + if (instruction.supressUseDomain) { + userId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + } else { + DomainRef ref = factory.newReference(idDomain); + userId.setDataType(ref); + } + userId.setLogicalName("ユーザID"); + tableUser.getAttributes().add(userId); + + userName = factory.newModel(ColumnModel.class, uuid.get("dacc68d2-fe32-4f4b-8082-9d55232ba7da")); + userName.setName("NAME"); + if (instruction.supressUseDomain) { + BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + dataType.getAdapter(SizedDataTypeAdapter.class).setSize(32); // CHECKSTYLE IGNORE THIS LINE + userName.setDataType(dataType); + } else { + DomainRef ref = factory.newReference(nameDomain); + userName.setDataType(ref); + } + userName.setLogicalName("ユーザ名"); + userName.setDefaultValue("no name"); + userName.getAdapter(RepresentationAdapter.class).setRepresentation(true); + tableUser.getAttributes().add(userName); + + userPk = factory.newModel(PrimaryKey.class, uuid.get("dac295e3-c390-46ee-9a5b-e89636ab9d7e")); + userPk.getKeyColumns().add(factory.newReference(userId)); + tableUser.getAttributes().add(userPk); + + NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); + userName.setNotNullConstraint(notNull); + } +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/Instruction.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/Instruction.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/Instruction.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,37 +1,37 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/23 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test; - -/** - * {@link CoreTestModelBuilder}等に対する指示クラス。 - * - * @author daisuke - */ -public class Instruction { - - /** ドメインを使用しない場合は{@code true}、そうでない場合は{@code false}を設定する */ - public boolean supressUseDomain; - - /** 外部キーを使用しない場合は{@code true}、そうでない場合は{@code false}を設定する */ - public boolean supressUseForeignKey; - - /** DataSetを使用しない場合は{@code true}、そうでない場合は{@code false}を設定する */ - public boolean supressUseDataSet; - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/23 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test; + +/** + * {@link CoreTestModelBuilder}等に対する指示クラス。 + * + * @author daisuke + */ +public class Instruction { + + /** ドメインを使用しない場合は{@code true}、そうでない場合は{@code false}を設定する */ + public boolean supressUseDomain; + + /** 外部キーを使用しない場合は{@code true}、そうでない場合は{@code false}を設定する */ + public boolean supressUseForeignKey; + + /** DataSetを使用しない場合は{@code true}、そうでない場合は{@code false}を設定する */ + public boolean supressUseDataSet; + +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/Instruction.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/JiemamyAssert.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/JiemamyAssert.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/JiemamyAssert.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,72 +1,72 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/05/09 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test; - -import java.lang.ref.SoftReference; -import java.lang.ref.WeakReference; -import java.util.LinkedList; - -/** - * Jiemamyプロジェクト用の、特殊JUnitアサーション集。 - * - * <p>cf. http://d.hatena.ne.jp/ashigeru/20080506/1210092877</p> - * - * @author daisuke - */ -public class JiemamyAssert { - - private static final int ALLOCATE_SIZE = 65536; - - - /** - * GCを発生させ、指定した弱参照が解放されることを表明する。 - * - * @param ref 弱参照 - */ - public static void assertGc(WeakReference<?> ref) { - SoftReference<LinkedList<int[]>> memoryEater1 = new SoftReference<LinkedList<int[]>>(new LinkedList<int[]>()); - SoftReference<LinkedList<int[]>> memoryEater2 = new SoftReference<LinkedList<int[]>>(new LinkedList<int[]>()); - - while (true) { - System.gc(); - if (consumeMemory(memoryEater1)) { - break; - } - if (consumeMemory(memoryEater2)) { - break; - } - } - - if (ref.get() != null) { - throw new AssertionError(); - } - } - - private static boolean consumeMemory(SoftReference<LinkedList<int[]>> eater) { - LinkedList<int[]> list = eater.get(); - if (list == null) { - return true; - } - list.add(new int[ALLOCATE_SIZE]); - return false; - } - - private JiemamyAssert() { - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/05/09 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test; + +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.LinkedList; + +/** + * Jiemamyプロジェクト用の、特殊JUnitアサーション集。 + * + * <p>cf. http://d.hatena.ne.jp/ashigeru/20080506/1210092877</p> + * + * @author daisuke + */ +public class JiemamyAssert { + + private static final int ALLOCATE_SIZE = 65536; + + + /** + * GCを発生させ、指定した弱参照が解放されることを表明する。 + * + * @param ref 弱参照 + */ + public static void assertGc(WeakReference<?> ref) { + SoftReference<LinkedList<int[]>> memoryEater1 = new SoftReference<LinkedList<int[]>>(new LinkedList<int[]>()); + SoftReference<LinkedList<int[]>> memoryEater2 = new SoftReference<LinkedList<int[]>>(new LinkedList<int[]>()); + + while (true) { + System.gc(); + if (consumeMemory(memoryEater1)) { + break; + } + if (consumeMemory(memoryEater2)) { + break; + } + } + + if (ref.get() != null) { + throw new AssertionError(); + } + } + + private static boolean consumeMemory(SoftReference<LinkedList<int[]>> eater) { + LinkedList<int[]> list = eater.get(); + if (list == null) { + return true; + } + list.add(new int[ALLOCATE_SIZE]); + return false; + } + + private JiemamyAssert() { + } +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/JiemamyAssert.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/ModelUtil.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/ModelUtil.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/ModelUtil.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,66 +1,66 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/04/06 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.Jiemamy; -import org.jiemamy.JiemamyFactory; -import org.jiemamy.dialect.BuiltinDataTypeMold; -import org.jiemamy.dialect.Dialect; -import org.jiemamy.exception.UnexpectedConditionError; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.attribute.ColumnModel; -import org.jiemamy.model.attribute.ColumnRef; -import org.jiemamy.model.dataset.RecordModel; -import org.jiemamy.model.datatype.BuiltinDataType; -import org.jiemamy.model.datatype.DataTypeCategory; - -/** - * {@link TestModelBuilder}がモデル生成時に用いるユーティリティクラス。 - * - * @author daisuke - */ -final class ModelUtil { - - static void addValue(RecordModel recordModel, ColumnModel columnModel, String value) { - Validate.notNull(recordModel); - Validate.notNull(columnModel); - - JiemamyFactory factory = columnModel.getJiemamy().getFactory(); - ColumnRef ref = factory.newReference(columnModel); - recordModel.getValues().put(ref, value); - } - - static BuiltinDataType createDataType(Jiemamy jiemamy, DataTypeCategory category) { - JiemamyFactory factory = jiemamy.getFactory(); - RootModel rootModel = factory.getRootModel(); - try { - Dialect dialect = jiemamy.getServiceLocator().getService(Dialect.class, rootModel.getDialectClassName()); - BuiltinDataTypeMold mold = dialect.getDataTypeResolver().findDataTypeMold(category); - return factory.newDataType(mold); - } catch (ClassNotFoundException e) { - throw new UnexpectedConditionError("Dialectのロスト", e); - } - } - - private ModelUtil() { - throw new UnexpectedConditionError("不到達ポイント"); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/04/06 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.Jiemamy; +import org.jiemamy.JiemamyFactory; +import org.jiemamy.dialect.BuiltinDataTypeMold; +import org.jiemamy.dialect.Dialect; +import org.jiemamy.exception.UnexpectedConditionError; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.ColumnRef; +import org.jiemamy.model.dataset.RecordModel; +import org.jiemamy.model.datatype.BuiltinDataType; +import org.jiemamy.model.datatype.DataTypeCategory; + +/** + * {@link TestModelBuilder}がモデル生成時に用いるユーティリティクラス。 + * + * @author daisuke + */ +final class ModelUtil { + + static void addValue(RecordModel recordModel, ColumnModel columnModel, String value) { + Validate.notNull(recordModel); + Validate.notNull(columnModel); + + JiemamyFactory factory = columnModel.getJiemamy().getFactory(); + ColumnRef ref = factory.newReference(columnModel); + recordModel.getValues().put(ref, value); + } + + static BuiltinDataType createDataType(Jiemamy jiemamy, DataTypeCategory category) { + JiemamyFactory factory = jiemamy.getFactory(); + RootModel rootModel = factory.getRootModel(); + try { + Dialect dialect = jiemamy.getServiceLocator().getService(Dialect.class, rootModel.getDialectClassName()); + BuiltinDataTypeMold mold = dialect.getDataTypeResolver().findDataTypeMold(category); + return factory.newDataType(mold); + } catch (ClassNotFoundException e) { + throw new UnexpectedConditionError("Dialectのロスト", e); + } + } + + private ModelUtil() { + throw new UnexpectedConditionError("不到達ポイント"); + } +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/ModelUtil.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,44 +1,44 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/04/04 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test; - -import org.jiemamy.Jiemamy; - -/** - * テストモデルを構築するテスト用ロジックのインターフェイス。 - * - * @author daisuke - */ -public interface TestModelBuilder { - - /** - * モデルをビルドする。 - * - * @return ビルドしたモデルのJiemamyコンテキスト - */ - Jiemamy build(); - - /** - * モデルをビルドする。 - * - * @param dialectClassName SQL方言クラス名 - * @return ビルドしたモデルのJiemamyコンテキスト - */ - Jiemamy build(String dialectClassName); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/04/04 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test; + +import org.jiemamy.Jiemamy; + +/** + * テストモデルを構築するテスト用ロジックのインターフェイス。 + * + * @author daisuke + */ +public interface TestModelBuilder { + + /** + * モデルをビルドする。 + * + * @return ビルドしたモデルのJiemamyコンテキスト + */ + Jiemamy build(); + + /** + * モデルをビルドする。 + * + * @param dialectClassName SQL方言クラス名 + * @return ビルドしたモデルのJiemamyコンテキスト + */ + Jiemamy build(String dialectClassName); +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,97 +1,97 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/04/04 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test; - -import java.io.InputStream; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.CharEncoding; - -import org.jiemamy.Jiemamy; -import org.jiemamy.exception.UnexpectedConditionError; -import org.jiemamy.internal.test.mock.MockServiceLocator; - -/** - * テスト用モデルの構築を行うビルダを供給するプロバイダ。 - * - * @author daisuke - */ -public enum TestModelBuilders { - - /** */ - EMP_DEPT(new CoreTestModelBuilder(newJiemamy()), getXml("/sample.xml")), - - /** */ - ORDER(new CoreTestModelBuilder2(newJiemamy()), getXml("/sample.xml")); - - private static String getXml(String path) { - InputStream in = TestModelBuilders.class.getResourceAsStream(path); - String xml; - try { - xml = IOUtils.toString(in, CharEncoding.UTF_8); - } catch (Exception e) { - throw new UnexpectedConditionError("リソースにアクセスできない", e); - } - return xml; - } - - private static Jiemamy newJiemamy() { - return Jiemamy.newInstance(new MockServiceLocator()); - } - - - private final TestModelBuilder builder; - - private final String xml; - - - TestModelBuilders(TestModelBuilder builder, String xml) { - this.builder = builder; - this.xml = xml; - } - - /** - * モデルをビルドし、Jiemamyコンテキストを取得する。 - * - * @return Jiemamyコンテキスト - */ - public Jiemamy getBuiltModel() { - return builder.build(); - } - - /** - * モデルをビルドし、Jiemamyコンテキストを取得する。 - * - * @param dialectClassName SQL方言クラス名 - * @return Jiemamyコンテキスト - */ - public Jiemamy getBuiltModel(String dialectClassName) { - return builder.build(dialectClassName); - } - - /** - * XML文字列を取得する。 - * - * @return XML文字列 - */ - public String getXml() { - return xml; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/04/04 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test; + +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.CharEncoding; + +import org.jiemamy.Jiemamy; +import org.jiemamy.exception.UnexpectedConditionError; +import org.jiemamy.internal.test.mock.MockServiceLocator; + +/** + * テスト用モデルの構築を行うビルダを供給するプロバイダ。 + * + * @author daisuke + */ +public enum TestModelBuilders { + + /** */ + EMP_DEPT(new CoreTestModelBuilder(newJiemamy()), getXml("/sample.xml")), + + /** */ + ORDER(new CoreTestModelBuilder2(newJiemamy()), getXml("/sample.xml")); + + private static String getXml(String path) { + InputStream in = TestModelBuilders.class.getResourceAsStream(path); + String xml; + try { + xml = IOUtils.toString(in, CharEncoding.UTF_8); + } catch (Exception e) { + throw new UnexpectedConditionError("リソースにアクセスできない", e); + } + return xml; + } + + private static Jiemamy newJiemamy() { + return Jiemamy.newInstance(new MockServiceLocator()); + } + + + private final TestModelBuilder builder; + + private final String xml; + + + TestModelBuilders(TestModelBuilder builder, String xml) { + this.builder = builder; + this.xml = xml; + } + + /** + * モデルをビルドし、Jiemamyコンテキストを取得する。 + * + * @return Jiemamyコンテキスト + */ + public Jiemamy getBuiltModel() { + return builder.build(); + } + + /** + * モデルをビルドし、Jiemamyコンテキストを取得する。 + * + * @param dialectClassName SQL方言クラス名 + * @return Jiemamyコンテキスト + */ + public Jiemamy getBuiltModel(String dialectClassName) { + return builder.build(dialectClassName); + } + + /** + * XML文字列を取得する。 + * + * @return XML文字列 + */ + public String getXml() { + return xml; + } + +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelsTestBase.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelsTestBase.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelsTestBase.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,55 +1,55 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/04/04 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test; - -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * {@link TestModelBuilder}で生成したモデルを使用してテストを行う為の基底クラス。 - * - * @author daisuke - */ -public abstract class TestModelsTestBase { - - private static Logger logger = LoggerFactory.getLogger(TestModelsTestBase.class); - - - /** - * テストを行う。 - * - * @param entry テストモデルのエントリ - * @throws Exception 例外が発生した場合 - */ - public abstract void doTest(TestModelBuilders entry) throws Exception; - - /** - * 全ての {@link TestModelBuilder}でテストを行うテストメソッド。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void testAllEntries() throws Exception { - for (TestModelBuilders entry : TestModelBuilders.values()) { - logger.info("==== Test Model: " + entry.name()); - doTest(entry); - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/04/04 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test; + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * {@link TestModelBuilder}で生成したモデルを使用してテストを行う為の基底クラス。 + * + * @author daisuke + */ +public abstract class TestModelsTestBase { + + private static Logger logger = LoggerFactory.getLogger(TestModelsTestBase.class); + + + /** + * テストを行う。 + * + * @param entry テストモデルのエントリ + * @throws Exception 例外が発生した場合 + */ + public abstract void doTest(TestModelBuilders entry) throws Exception; + + /** + * 全ての {@link TestModelBuilder}でテストを行うテストメソッド。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void testAllEntries() throws Exception { + for (TestModelBuilders entry : TestModelBuilders.values()) { + logger.info("==== Test Model: " + entry.name()); + doTest(entry); + } + } +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/TestModelsTestBase.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/UuidStrategy.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/UuidStrategy.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/UuidStrategy.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,49 +1,49 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/23 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test; - -import java.util.UUID; - -/** - * テストモデルを組み立てる際、モデルIDをランダム生成するか、毎回固定で生成するかを決める戦略クラス。 - * - * @author daisuke - */ -public enum UuidStrategy { - - /** 固定 */ - FIXED { - - @Override - UUID get(String name) { - return UUID.fromString(name); - } - }, - - /** 都度生成 */ - GENERATE { - - @Override - UUID get(String name) { - return UUID.randomUUID(); - } - }; - - abstract UUID get(String name); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/23 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test; + +import java.util.UUID; + +/** + * テストモデルを組み立てる際、モデルIDをランダム生成するか、毎回固定で生成するかを決める戦略クラス。 + * + * @author daisuke + */ +public enum UuidStrategy { + + /** 固定 */ + FIXED { + + @Override + UUID get(String name) { + return UUID.fromString(name); + } + }, + + /** 都度生成 */ + GENERATE { + + @Override + UUID get(String name) { + return UUID.randomUUID(); + } + }; + + abstract UUID get(String name); +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/UuidStrategy.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,207 +1,207 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/22 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test; - -import java.util.List; - -import org.jiemamy.Jiemamy; -import org.jiemamy.OfficialSpecs; -import org.jiemamy.model.ConnectionProfile; -import org.jiemamy.model.DiagramPresentationModel; -import org.jiemamy.model.DiagramPresentations; -import org.jiemamy.model.NodeProfile; -import org.jiemamy.model.connection.ConnectionAdapter; -import org.jiemamy.model.geometory.JmColor; -import org.jiemamy.model.geometory.JmPoint; -import org.jiemamy.model.geometory.JmRectangle; -import org.jiemamy.model.node.NodeAdapter; -import org.jiemamy.model.node.StickyModel; - -/** - * Jiemamy VIEW仕様範囲を含めたJiemamyテストモデル1(EMP-DEPTテーブル)を組み立てるビルダ。 - * - * @author daisuke - */ -public class ViewTestModelBuilder extends CoreTestModelBuilder { - - /** StickyModel for Test */ - protected StickyModel sticky; - - private static final int OFFSET = 50; - - - /** - * インスタンスを生成する。 - */ - public ViewTestModelBuilder() { - super(); - } - - /** - * インスタンスを生成する。 - * - * @param instruction 設定オブジェクト - */ - public ViewTestModelBuilder(Instruction instruction) { - super(instruction); - } - - /** - * インスタンスを生成する。 - * - * @param instruction 設定オブジェクト - * @param jiemamy コンテキスト - */ - public ViewTestModelBuilder(Instruction instruction, Jiemamy jiemamy) { - super(instruction, jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param jiemamy コンテキスト - */ - public ViewTestModelBuilder(Jiemamy jiemamy) { - super(jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - */ - public ViewTestModelBuilder(UuidStrategy uuid) { - super(uuid); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param instruction 設定オブジェクト - */ - public ViewTestModelBuilder(UuidStrategy uuid, Instruction instruction) { - super(uuid, instruction); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param instruction 設定オブジェクト - * @param jiemamy コンテキスト - */ - public ViewTestModelBuilder(UuidStrategy uuid, Instruction instruction, Jiemamy jiemamy) { - super(uuid, instruction, jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param jiemamy コンテキスト - */ - public ViewTestModelBuilder(UuidStrategy uuid, Jiemamy jiemamy) { - super(uuid, jiemamy); - } - - @Override - public Jiemamy build() { - Jiemamy jiemamy = super.build(); - createPresentations(); - - return jiemamy; - } - - @Override - protected void createEntities() { - super.createEntities(); - if (factory.getSupportedSpecs().contains(OfficialSpecs.VIEW)) { - sticky = factory.newModel(StickyModel.class, uuid.get("43beb884-2562-4480-8030-bb797f701783")); - sticky.setContents("メモーー"); - } - } - - private void createPresentations() { - if (factory.getSupportedSpecs().contains(OfficialSpecs.VIEW)) { - DiagramPresentations diagramPresentations = rootModel.getAdapter(DiagramPresentations.class); - - // ダイアグラム表現の生成・追加(1) - DiagramPresentationModel presentation1 = - factory.newModel(DiagramPresentationModel.class, uuid.get("1deca0e8-6153-47ad-abe8-ac764f768d96")); - presentation1.setName("全部表示する"); - - NodeProfile empProfile = - factory.newModel(NodeProfile.class, uuid.get("aa7caa23-7958-4bd0-a356-8f09d4b74f08")); - presentation1.getNodeProfiles().put(tableEmp.getAdapter(NodeAdapter.class), empProfile); - empProfile.setBoundary(new JmRectangle(360, 60)); // CHECKSTYLE IGNORE THIS LINE - - NodeProfile deptProfile = - factory.newModel(NodeProfile.class, uuid.get("eb6506ef-4a25-4296-b6d7-c08741f19d5a")); - presentation1.getNodeProfiles().put(tableDept.getAdapter(NodeAdapter.class), deptProfile); - deptProfile.setBoundary(new JmRectangle(60, 60)); // CHECKSTYLE IGNORE THIS LINE - - NodeProfile viewProfile = - factory.newModel(NodeProfile.class, uuid.get("2387bfd0-7106-44ad-a34e-24231bbea6d5")); - presentation1.getNodeProfiles().put(viewHighSal.getAdapter(NodeAdapter.class), viewProfile); - viewProfile.setBoundary(new JmRectangle(60, 270)); // CHECKSTYLE IGNORE THIS LINE - - NodeProfile stickyProfile = - factory.newModel(NodeProfile.class, uuid.get("2689d193-52a1-4fd4-a14c-9857274518c5")); - presentation1.getNodeProfiles().put(sticky, stickyProfile); - stickyProfile.setBoundary(new JmRectangle(360, 270)); // CHECKSTYLE IGNORE THIS LINE - stickyProfile.setColor(new JmColor(10, 11, 12)); - - ConnectionProfile connectionProfile1 = - factory.newModel(ConnectionProfile.class, uuid.get("366b547f-a2a6-42b2-a3a4-38745436c425")); - List<JmPoint> bendpoints = connectionProfile1.getBendpoints(); - NodeProfile nodeProf = presentation1.getNodeProfiles().get(tableEmp.getAdapter(NodeAdapter.class)); - JmRectangle boundary = nodeProf.getBoundary(); - bendpoints.add(0, new JmPoint(Math.max(boundary.x - OFFSET, 0), boundary.y)); - bendpoints.add(1, new JmPoint(boundary.x, Math.max(boundary.y - OFFSET, 0))); - presentation1.getConnectionProfiles().put(fkEmpEmp.getAdapter(ConnectionAdapter.class), connectionProfile1); - - ConnectionProfile connectionProfile2 = - factory.newModel(ConnectionProfile.class, uuid.get("e5b3d709-2aea-4e26-a90c-b8f438d2da9d")); - presentation1.getConnectionProfiles() - .put(fkEmpDept.getAdapter(ConnectionAdapter.class), connectionProfile2); - diagramPresentations.add(presentation1); - - // ダイアグラム表現の生成・追加(2) - DiagramPresentationModel presentation2 = - factory.newModel(DiagramPresentationModel.class, uuid.get("53c7cdb7-1512-46c7-8ee3-aadec6007896")); - presentation2.setName("一部表示する"); - - NodeProfile nodeProfile1 = - factory.newModel(NodeProfile.class, uuid.get("d71ff015-101c-4669-8745-312d1da34efe")); - presentation2.getNodeProfiles().put(tableEmp.getAdapter(NodeAdapter.class), nodeProfile1); - nodeProfile1.setBoundary(new JmRectangle(60, 60)); // CHECKSTYLE IGNORE THIS LINE - - NodeProfile nodeProfile2 = - factory.newModel(NodeProfile.class, uuid.get("2df7718f-d71e-4dbf-8327-e0ad36f03d5d")); - presentation2.getNodeProfiles().put(viewHighSal.getAdapter(NodeAdapter.class), nodeProfile2); - nodeProfile2.setBoundary(new JmRectangle(270, 270)); // CHECKSTYLE IGNORE THIS LINE - - ConnectionProfile connectionProfile = - factory.newModel(ConnectionProfile.class, uuid.get("b615f111-5143-4b12-bfdb-9a06806a9ace")); - presentation2.getConnectionProfiles().put(fkEmpDept.getAdapter(ConnectionAdapter.class), connectionProfile); - diagramPresentations.add(presentation2); - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/22 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test; + +import java.util.List; + +import org.jiemamy.Jiemamy; +import org.jiemamy.OfficialSpecs; +import org.jiemamy.model.ConnectionProfile; +import org.jiemamy.model.DiagramPresentationModel; +import org.jiemamy.model.DiagramPresentations; +import org.jiemamy.model.NodeProfile; +import org.jiemamy.model.connection.ConnectionAdapter; +import org.jiemamy.model.geometory.JmColor; +import org.jiemamy.model.geometory.JmPoint; +import org.jiemamy.model.geometory.JmRectangle; +import org.jiemamy.model.node.NodeAdapter; +import org.jiemamy.model.node.StickyModel; + +/** + * Jiemamy VIEW仕様範囲を含めたJiemamyテストモデル1(EMP-DEPTテーブル)を組み立てるビルダ。 + * + * @author daisuke + */ +public class ViewTestModelBuilder extends CoreTestModelBuilder { + + /** StickyModel for Test */ + protected StickyModel sticky; + + private static final int OFFSET = 50; + + + /** + * インスタンスを生成する。 + */ + public ViewTestModelBuilder() { + super(); + } + + /** + * インスタンスを生成する。 + * + * @param instruction 設定オブジェクト + */ + public ViewTestModelBuilder(Instruction instruction) { + super(instruction); + } + + /** + * インスタンスを生成する。 + * + * @param instruction 設定オブジェクト + * @param jiemamy コンテキスト + */ + public ViewTestModelBuilder(Instruction instruction, Jiemamy jiemamy) { + super(instruction, jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param jiemamy コンテキスト + */ + public ViewTestModelBuilder(Jiemamy jiemamy) { + super(jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + */ + public ViewTestModelBuilder(UuidStrategy uuid) { + super(uuid); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param instruction 設定オブジェクト + */ + public ViewTestModelBuilder(UuidStrategy uuid, Instruction instruction) { + super(uuid, instruction); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param instruction 設定オブジェクト + * @param jiemamy コンテキスト + */ + public ViewTestModelBuilder(UuidStrategy uuid, Instruction instruction, Jiemamy jiemamy) { + super(uuid, instruction, jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param jiemamy コンテキスト + */ + public ViewTestModelBuilder(UuidStrategy uuid, Jiemamy jiemamy) { + super(uuid, jiemamy); + } + + @Override + public Jiemamy build() { + Jiemamy jiemamy = super.build(); + createPresentations(); + + return jiemamy; + } + + @Override + protected void createEntities() { + super.createEntities(); + if (factory.getSupportedSpecs().contains(OfficialSpecs.VIEW)) { + sticky = factory.newModel(StickyModel.class, uuid.get("43beb884-2562-4480-8030-bb797f701783")); + sticky.setContents("メモーー"); + } + } + + private void createPresentations() { + if (factory.getSupportedSpecs().contains(OfficialSpecs.VIEW)) { + DiagramPresentations diagramPresentations = rootModel.getAdapter(DiagramPresentations.class); + + // ダイアグラム表現の生成・追加(1) + DiagramPresentationModel presentation1 = + factory.newModel(DiagramPresentationModel.class, uuid.get("1deca0e8-6153-47ad-abe8-ac764f768d96")); + presentation1.setName("全部表示する"); + + NodeProfile empProfile = + factory.newModel(NodeProfile.class, uuid.get("aa7caa23-7958-4bd0-a356-8f09d4b74f08")); + presentation1.getNodeProfiles().put(tableEmp.getAdapter(NodeAdapter.class), empProfile); + empProfile.setBoundary(new JmRectangle(360, 60)); // CHECKSTYLE IGNORE THIS LINE + + NodeProfile deptProfile = + factory.newModel(NodeProfile.class, uuid.get("eb6506ef-4a25-4296-b6d7-c08741f19d5a")); + presentation1.getNodeProfiles().put(tableDept.getAdapter(NodeAdapter.class), deptProfile); + deptProfile.setBoundary(new JmRectangle(60, 60)); // CHECKSTYLE IGNORE THIS LINE + + NodeProfile viewProfile = + factory.newModel(NodeProfile.class, uuid.get("2387bfd0-7106-44ad-a34e-24231bbea6d5")); + presentation1.getNodeProfiles().put(viewHighSal.getAdapter(NodeAdapter.class), viewProfile); + viewProfile.setBoundary(new JmRectangle(60, 270)); // CHECKSTYLE IGNORE THIS LINE + + NodeProfile stickyProfile = + factory.newModel(NodeProfile.class, uuid.get("2689d193-52a1-4fd4-a14c-9857274518c5")); + presentation1.getNodeProfiles().put(sticky, stickyProfile); + stickyProfile.setBoundary(new JmRectangle(360, 270)); // CHECKSTYLE IGNORE THIS LINE + stickyProfile.setColor(new JmColor(10, 11, 12)); + + ConnectionProfile connectionProfile1 = + factory.newModel(ConnectionProfile.class, uuid.get("366b547f-a2a6-42b2-a3a4-38745436c425")); + List<JmPoint> bendpoints = connectionProfile1.getBendpoints(); + NodeProfile nodeProf = presentation1.getNodeProfiles().get(tableEmp.getAdapter(NodeAdapter.class)); + JmRectangle boundary = nodeProf.getBoundary(); + bendpoints.add(0, new JmPoint(Math.max(boundary.x - OFFSET, 0), boundary.y)); + bendpoints.add(1, new JmPoint(boundary.x, Math.max(boundary.y - OFFSET, 0))); + presentation1.getConnectionProfiles().put(fkEmpEmp.getAdapter(ConnectionAdapter.class), connectionProfile1); + + ConnectionProfile connectionProfile2 = + factory.newModel(ConnectionProfile.class, uuid.get("e5b3d709-2aea-4e26-a90c-b8f438d2da9d")); + presentation1.getConnectionProfiles() + .put(fkEmpDept.getAdapter(ConnectionAdapter.class), connectionProfile2); + diagramPresentations.add(presentation1); + + // ダイアグラム表現の生成・追加(2) + DiagramPresentationModel presentation2 = + factory.newModel(DiagramPresentationModel.class, uuid.get("53c7cdb7-1512-46c7-8ee3-aadec6007896")); + presentation2.setName("一部表示する"); + + NodeProfile nodeProfile1 = + factory.newModel(NodeProfile.class, uuid.get("d71ff015-101c-4669-8745-312d1da34efe")); + presentation2.getNodeProfiles().put(tableEmp.getAdapter(NodeAdapter.class), nodeProfile1); + nodeProfile1.setBoundary(new JmRectangle(60, 60)); // CHECKSTYLE IGNORE THIS LINE + + NodeProfile nodeProfile2 = + factory.newModel(NodeProfile.class, uuid.get("2df7718f-d71e-4dbf-8327-e0ad36f03d5d")); + presentation2.getNodeProfiles().put(viewHighSal.getAdapter(NodeAdapter.class), nodeProfile2); + nodeProfile2.setBoundary(new JmRectangle(270, 270)); // CHECKSTYLE IGNORE THIS LINE + + ConnectionProfile connectionProfile = + factory.newModel(ConnectionProfile.class, uuid.get("b615f111-5143-4b12-bfdb-9a06806a9ace")); + presentation2.getConnectionProfiles().put(fkEmpDept.getAdapter(ConnectionAdapter.class), connectionProfile); + diagramPresentations.add(presentation2); + } + } +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockBuiltinDataType.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockBuiltinDataType.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockBuiltinDataType.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,71 +1,71 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/09/02 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test.mock; - -import java.util.List; - -import org.apache.commons.collections15.ListUtils; - -import org.jiemamy.ReferenceResolver; -import org.jiemamy.model.datatype.BuiltinDataType; -import org.jiemamy.model.datatype.DataTypeCategory; -import org.jiemamy.utils.AdapterNotFoundException; - -class MockBuiltinDataType implements BuiltinDataType { - - public <T>T getAdapter(Class<T> adapterClass) { - throw new AdapterNotFoundException(adapterClass); - } - - @SuppressWarnings("unchecked") - // 空のコレクションなので問題ない - public List<Object> getAdapters() { - return ListUtils.EMPTY_LIST; - } - - public DataTypeCategory getCategory() { - return DataTypeCategory.OTHER; - } - - public String getTypeName() { - return "OTHER"; - } - - public boolean hasAdapter(Class<?> adapterClass) { - return false; - } - - public void registerAdapter(Object adapter) { - } - - public void setCategory(DataTypeCategory category) { - } - - public void setTypeName(String typeName) { - } - - public BuiltinDataType toBuiltinDataType(ReferenceResolver resolver) { - return this; - } - - public <T>T unregisterAdapter(Class<T> adapterClass) { - throw new AdapterNotFoundException(adapterClass); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/09/02 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test.mock; + +import java.util.List; + +import org.apache.commons.collections15.ListUtils; + +import org.jiemamy.ReferenceResolver; +import org.jiemamy.model.datatype.BuiltinDataType; +import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.utils.AdapterNotFoundException; + +class MockBuiltinDataType implements BuiltinDataType { + + public <T>T getAdapter(Class<T> adapterClass) { + throw new AdapterNotFoundException(adapterClass); + } + + @SuppressWarnings("unchecked") + // 空のコレクションなので問題ない + public List<Object> getAdapters() { + return ListUtils.EMPTY_LIST; + } + + public DataTypeCategory getCategory() { + return DataTypeCategory.OTHER; + } + + public String getTypeName() { + return "OTHER"; + } + + public boolean hasAdapter(Class<?> adapterClass) { + return false; + } + + public void registerAdapter(Object adapter) { + } + + public void setCategory(DataTypeCategory category) { + } + + public void setTypeName(String typeName) { + } + + public BuiltinDataType toBuiltinDataType(ReferenceResolver resolver) { + return this; + } + + public <T>T unregisterAdapter(Class<T> adapterClass) { + throw new AdapterNotFoundException(adapterClass); + } + +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockBuiltinDataType.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockBuiltinDataTypeMold.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockBuiltinDataTypeMold.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockBuiltinDataTypeMold.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,67 +1,67 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/09/02 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test.mock; - -import java.util.ArrayList; -import java.util.Collection; - -import org.apache.commons.collections15.CollectionUtils; - -import org.jiemamy.dialect.BuiltinDataTypeMold; -import org.jiemamy.model.datatype.DataTypeCategory; -import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; -import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; -import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; -import org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter; - -/** - * {@link BuiltinDataTypeMold}のモックオブジェクト。 - * - * @author daisuke - */ -public class MockBuiltinDataTypeMold implements BuiltinDataTypeMold { - - @SuppressWarnings("unchecked") - // 空のコレクションなので問題ない - public Collection<String> getAliases() { - return CollectionUtils.EMPTY_COLLECTION; - } - - public DataTypeCategory getCategory() { - return DataTypeCategory.OTHER; - } - - public String getName() { - return "OTHER"; - } - - public Collection<Class<?>> getSupportedAdapterClasses() { - return new ArrayList<Class<?>>() { - - private static final long serialVersionUID = 3681125761407179702L; - - { - add(SerialDataTypeAdapter.class); - add(SizedDataTypeAdapter.class); - add(PrecisionedDataTypeAdapter.class); - add(TimezonedDataTypeAdapter.class); - } - }; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/09/02 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test.mock; + +import java.util.ArrayList; +import java.util.Collection; + +import org.apache.commons.collections15.CollectionUtils; + +import org.jiemamy.dialect.BuiltinDataTypeMold; +import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter; + +/** + * {@link BuiltinDataTypeMold}のモックオブジェクト。 + * + * @author daisuke + */ +public class MockBuiltinDataTypeMold implements BuiltinDataTypeMold { + + @SuppressWarnings("unchecked") + // 空のコレクションなので問題ない + public Collection<String> getAliases() { + return CollectionUtils.EMPTY_COLLECTION; + } + + public DataTypeCategory getCategory() { + return DataTypeCategory.OTHER; + } + + public String getName() { + return "OTHER"; + } + + public Collection<Class<?>> getSupportedAdapterClasses() { + return new ArrayList<Class<?>>() { + + private static final long serialVersionUID = 3681125761407179702L; + + { + add(SerialDataTypeAdapter.class); + add(SizedDataTypeAdapter.class); + add(PrecisionedDataTypeAdapter.class); + add(TimezonedDataTypeAdapter.class); + } + }; + } +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockBuiltinDataTypeMold.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDataTypeResolver.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDataTypeResolver.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDataTypeResolver.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,80 +1,80 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/09/02 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test.mock; - -import java.util.ArrayList; -import java.util.List; - -import org.jiemamy.JiemamyFactory; -import org.jiemamy.ReferenceResolver; -import org.jiemamy.dialect.BuiltinDataTypeMold; -import org.jiemamy.dialect.DataTypeResolver; -import org.jiemamy.model.datatype.BuiltinDataType; -import org.jiemamy.model.datatype.DataType; -import org.jiemamy.model.datatype.DataTypeCategory; -import org.jiemamy.model.sql.Token; - -/** - * {@link DataTypeResolver}のモックオブジェクト。 - * - * @author daisuke - */ -public class MockDataTypeResolver implements DataTypeResolver { - - static List<BuiltinDataTypeMold> molds; - - static { - molds = new ArrayList<BuiltinDataTypeMold>(); - molds.add(new MockBuiltinDataTypeMold()); - } - - - public BuiltinDataTypeMold findDataTypeMold(BuiltinDataType builtinDataType) { - return molds.get(0); - } - - public BuiltinDataTypeMold findDataTypeMold(DataTypeCategory category) { - return molds.get(0); - } - - public BuiltinDataTypeMold findDataTypeMold(DataTypeCategory category, String typeName) { - return molds.get(0); - } - - public List<BuiltinDataTypeMold> getTypeList() { - return molds; - } - - public List<Token> resolveDataType(DataType dataType, ReferenceResolver resolver) { - List<Token> tokens = new ArrayList<Token>(); - tokens.add(new Token() { - - @Override - public String toString() { - return "OTHER"; - } - }); - return tokens; - } - - public BuiltinDataType resolveDataType(JiemamyFactory factory, int sqlType, String typeName) { - return new MockBuiltinDataType(); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/09/02 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test.mock; + +import java.util.ArrayList; +import java.util.List; + +import org.jiemamy.JiemamyFactory; +import org.jiemamy.ReferenceResolver; +import org.jiemamy.dialect.BuiltinDataTypeMold; +import org.jiemamy.dialect.DataTypeResolver; +import org.jiemamy.model.datatype.BuiltinDataType; +import org.jiemamy.model.datatype.DataType; +import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.sql.Token; + +/** + * {@link DataTypeResolver}のモックオブジェクト。 + * + * @author daisuke + */ +public class MockDataTypeResolver implements DataTypeResolver { + + static List<BuiltinDataTypeMold> molds; + + static { + molds = new ArrayList<BuiltinDataTypeMold>(); + molds.add(new MockBuiltinDataTypeMold()); + } + + + public BuiltinDataTypeMold findDataTypeMold(BuiltinDataType builtinDataType) { + return molds.get(0); + } + + public BuiltinDataTypeMold findDataTypeMold(DataTypeCategory category) { + return molds.get(0); + } + + public BuiltinDataTypeMold findDataTypeMold(DataTypeCategory category, String typeName) { + return molds.get(0); + } + + public List<BuiltinDataTypeMold> getTypeList() { + return molds; + } + + public List<Token> resolveDataType(DataType dataType, ReferenceResolver resolver) { + List<Token> tokens = new ArrayList<Token>(); + tokens.add(new Token() { + + @Override + public String toString() { + return "OTHER"; + } + }); + return tokens; + } + + public BuiltinDataType resolveDataType(JiemamyFactory factory, int sqlType, String typeName) { + return new MockBuiltinDataType(); + } + +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDataTypeResolver.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDialect.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDialect.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDialect.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,107 +1,107 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/09/02 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test.mock; - -import java.sql.DatabaseMetaData; -import java.util.List; -import java.util.Map; - -import org.apache.commons.collections15.ListUtils; -import org.apache.commons.lang.StringUtils; - -import org.jiemamy.Jiemamy; -import org.jiemamy.dialect.BuiltinDataTypeMold; -import org.jiemamy.dialect.DataTypeResolver; -import org.jiemamy.dialect.Dialect; -import org.jiemamy.dialect.EmitConfig; -import org.jiemamy.dialect.ImportMetadataConfig; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.attribute.constraint.ForeignKey; -import org.jiemamy.model.datatype.BuiltinDataType; -import org.jiemamy.model.datatype.DataTypeCategory; -import org.jiemamy.model.entity.EntityModel; -import org.jiemamy.model.sql.SqlStatement; -import org.jiemamy.validator.Validator; - -/** - * {@link Dialect}のモックオブジェクト。 - * - * @author daisuke - */ -public class MockDialect implements Dialect { - - MockDataTypeResolver mgr = new MockDataTypeResolver(); - - - @SuppressWarnings("unchecked") - // 空のコレクションなので問題ない - public List<SqlStatement> emitStatements(RootModel rootModel, EmitConfig config) { - return ListUtils.EMPTY_LIST; - } - - public BuiltinDataTypeMold findDataTypeMold(BuiltinDataType dataType) { - return mgr.findDataTypeMold(dataType); - } - - public BuiltinDataTypeMold findDataTypeMold(DataTypeCategory category) { - return mgr.findDataTypeMold(category); - } - - public BuiltinDataTypeMold findDataTypeMold(DataTypeCategory category, String typeName) { - return mgr.findDataTypeMold(category, typeName); - } - - public List<BuiltinDataTypeMold> getAllDataTypes() { - return mgr.getTypeList(); - } - - public String getConnectionUriTemplate() { - return StringUtils.EMPTY; - } - - public DataTypeResolver getDataTypeResolver() { - return new MockDataTypeResolver(); - } - - @Deprecated - public org.jiemamy.dialect.MoldManager getMoldManager() { - return mgr; - } - - public String getName() { - return "Mock Dialect"; - } - - public Validator getValidator() { - return new MockValidator(); - } - - public void importMetadata(RootModel rootModel, DatabaseMetaData meta, ImportMetadataConfig config, - Map<String, EntityModel> importedEntities, Map<String, ForeignKey> importedForeignKeys) { - } - - public RootModel parseStatements(List<SqlStatement> statements) { - return Jiemamy.newInstance().getFactory().getRootModel(); - } - - @Override - public String toString() { - return getClass().getName(); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/09/02 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test.mock; + +import java.sql.DatabaseMetaData; +import java.util.List; +import java.util.Map; + +import org.apache.commons.collections15.ListUtils; +import org.apache.commons.lang.StringUtils; + +import org.jiemamy.Jiemamy; +import org.jiemamy.dialect.BuiltinDataTypeMold; +import org.jiemamy.dialect.DataTypeResolver; +import org.jiemamy.dialect.Dialect; +import org.jiemamy.dialect.EmitConfig; +import org.jiemamy.dialect.ImportMetadataConfig; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.constraint.ForeignKey; +import org.jiemamy.model.datatype.BuiltinDataType; +import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.entity.EntityModel; +import org.jiemamy.model.sql.SqlStatement; +import org.jiemamy.validator.Validator; + +/** + * {@link Dialect}のモックオブジェクト。 + * + * @author daisuke + */ +public class MockDialect implements Dialect { + + MockDataTypeResolver mgr = new MockDataTypeResolver(); + + + @SuppressWarnings("unchecked") + // 空のコレクションなので問題ない + public List<SqlStatement> emitStatements(RootModel rootModel, EmitConfig config) { + return ListUtils.EMPTY_LIST; + } + + public BuiltinDataTypeMold findDataTypeMold(BuiltinDataType dataType) { + return mgr.findDataTypeMold(dataType); + } + + public BuiltinDataTypeMold findDataTypeMold(DataTypeCategory category) { + return mgr.findDataTypeMold(category); + } + + public BuiltinDataTypeMold findDataTypeMold(DataTypeCategory category, String typeName) { + return mgr.findDataTypeMold(category, typeName); + } + + public List<BuiltinDataTypeMold> getAllDataTypes() { + return mgr.getTypeList(); + } + + public String getConnectionUriTemplate() { + return StringUtils.EMPTY; + } + + public DataTypeResolver getDataTypeResolver() { + return new MockDataTypeResolver(); + } + + @Deprecated + public org.jiemamy.dialect.MoldManager getMoldManager() { + return mgr; + } + + public String getName() { + return "Mock Dialect"; + } + + public Validator getValidator() { + return new MockValidator(); + } + + public void importMetadata(RootModel rootModel, DatabaseMetaData meta, ImportMetadataConfig config, + Map<String, EntityModel> importedEntities, Map<String, ForeignKey> importedForeignKeys) { + } + + public RootModel parseStatements(List<SqlStatement> statements) { + return Jiemamy.newInstance().getFactory().getRootModel(); + } + + @Override + public String toString() { + return getClass().getName(); + } +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDialect.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDialectProvider.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDialectProvider.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDialectProvider.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,39 +1,39 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/09/02 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test.mock; - -import org.jiemamy.InstanceProvider; -import org.jiemamy.dialect.Dialect; - -/** - * DialectProviderのモックオブジェクト。 - * - * @author daisuke - */ - @ Deprecated -public class MockDialectProvider implements InstanceProvider<Dialect> { - - public Dialect getInstance(String fqcn) throws ClassNotFoundException { - if (MockDialect.class.getName().equals(fqcn)) { - return new MockDialect(); - } - throw new ClassNotFoundException(fqcn); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/09/02 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test.mock; + +import org.jiemamy.InstanceProvider; +import org.jiemamy.dialect.Dialect; + +/** + * DialectProviderのモックオブジェクト。 + * + * @author daisuke + */ + @ Deprecated +public class MockDialectProvider implements InstanceProvider<Dialect> { + + public Dialect getInstance(String fqcn) throws ClassNotFoundException { + if (MockDialect.class.getName().equals(fqcn)) { + return new MockDialect(); + } + throw new ClassNotFoundException(fqcn); + } + +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockDialectProvider.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockScriptEngine.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockScriptEngine.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockScriptEngine.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,36 +1,36 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/09/18 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test.mock; - -import org.jiemamy.model.script.ScriptEngine; -import org.jiemamy.utils.Advisable; - -/** - * {@link ScriptEngine}のモック実装。 - * - * @since 0.3 - * @author daisuke - */ -public class MockScriptEngine implements ScriptEngine { - - public String process(Advisable<?> target, String script) { - return ""; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/09/18 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test.mock; + +import org.jiemamy.model.script.ScriptEngine; +import org.jiemamy.utils.Advisable; + +/** + * {@link ScriptEngine}のモック実装。 + * + * @since 0.3 + * @author daisuke + */ +public class MockScriptEngine implements ScriptEngine { + + public String process(Advisable<?> target, String script) { + return ""; + } + +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockScriptEngine.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockServiceLocator.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockServiceLocator.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockServiceLocator.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,54 +1,54 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/09/02 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test.mock; - -import org.jiemamy.Jiemamy.DefaultServiceLocator; -import org.jiemamy.dialect.Dialect; -import org.jiemamy.model.script.ScriptEngine; - -/** - * DialectProviderのモックオブジェクト。 - * - * @author daisuke - */ -public class MockServiceLocator extends DefaultServiceLocator { - - @Override - public <T>T getService(Class<T> clazz, String fqcn) throws ClassNotFoundException { - try { - return super.getService(clazz, fqcn); - } catch (ClassNotFoundException e) { - if (Dialect.class.isAssignableFrom(clazz)) { - if (MockDialect.class.getName().equals(fqcn)) { - @SuppressWarnings("unchecked") - T result = (T) new MockDialect(); - return result; - } - } else if (ScriptEngine.class.isAssignableFrom(clazz)) { - if (MockScriptEngine.class.getName().equals(fqcn)) { - @SuppressWarnings("unchecked") - T result = (T) new MockScriptEngine(); - return result; - } - } - throw e; - } - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/09/02 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test.mock; + +import org.jiemamy.Jiemamy.DefaultServiceLocator; +import org.jiemamy.dialect.Dialect; +import org.jiemamy.model.script.ScriptEngine; + +/** + * DialectProviderのモックオブジェクト。 + * + * @author daisuke + */ +public class MockServiceLocator extends DefaultServiceLocator { + + @Override + public <T>T getService(Class<T> clazz, String fqcn) throws ClassNotFoundException { + try { + return super.getService(clazz, fqcn); + } catch (ClassNotFoundException e) { + if (Dialect.class.isAssignableFrom(clazz)) { + if (MockDialect.class.getName().equals(fqcn)) { + @SuppressWarnings("unchecked") + T result = (T) new MockDialect(); + return result; + } + } else if (ScriptEngine.class.isAssignableFrom(clazz)) { + if (MockScriptEngine.class.getName().equals(fqcn)) { + @SuppressWarnings("unchecked") + T result = (T) new MockScriptEngine(); + return result; + } + } + throw e; + } + } + +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockServiceLocator.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockValidator.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockValidator.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockValidator.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,42 +1,42 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/09/02 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test.mock; - -import java.util.Collection; - -import org.apache.commons.collections15.CollectionUtils; - -import org.jiemamy.model.RootModel; -import org.jiemamy.validator.Problem; -import org.jiemamy.validator.Validator; - -/** - * {@link Validator}のモックオブジェクト。 - * - * @author daisuke - */ -public class MockValidator implements Validator { - - @SuppressWarnings("unchecked") - // 空のコレクションなので問題ない - public Collection<Problem> validate(RootModel rootModel) { - return CollectionUtils.EMPTY_COLLECTION; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/09/02 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test.mock; + +import java.util.Collection; + +import org.apache.commons.collections15.CollectionUtils; + +import org.jiemamy.model.RootModel; +import org.jiemamy.validator.Problem; +import org.jiemamy.validator.Validator; + +/** + * {@link Validator}のモックオブジェクト。 + * + * @author daisuke + */ +public class MockValidator implements Validator { + + @SuppressWarnings("unchecked") + // 空のコレクションなので問題ない + public Collection<Problem> validate(RootModel rootModel) { + return CollectionUtils.EMPTY_COLLECTION; + } + +} Property changes on: zeus/trunk/jiemamy-test-helper/src/main/java/org/jiemamy/internal/test/mock/MockValidator.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/test/java/org/jiemamy/internal/test/JiemamyAssertTest.java =================================================================== --- zeus/trunk/jiemamy-test-helper/src/test/java/org/jiemamy/internal/test/JiemamyAssertTest.java 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/test/java/org/jiemamy/internal/test/JiemamyAssertTest.java 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,69 +1,69 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/05/09 - * - * This file is part of Jiemamy. - * - * 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.jiemamy.internal.test; - -import static org.junit.Assert.fail; - -import java.lang.ref.WeakReference; - -import org.junit.Test; - -/** - * {@link JiemamyAssert}のテストクラス。 - * - * <p>cf. http://d.hatena.ne.jp/ashigeru/20080506/1210092877</p> - * - * @author daisuke - */ -public class JiemamyAssertTest { - - /** - * Test method for {@link JiemamyAssert#assertGc(java.lang.ref.WeakReference)}. - */ - @Test - public void testAssertGc() { - Object obj = new String("Hello, world!"); - WeakReference<Object> ref = new WeakReference<Object>(obj); - - // keeps only weak references - obj = null; - - JiemamyAssert.assertGc(ref); - } - - /** - * Test method for {@link JiemamyAssert#assertGc(java.lang.ref.WeakReference)}. - */ - @Test - public void testAssertGcLeak() { - Object obj = new String("Hello, world!"); - WeakReference<Object> ref = new WeakReference<Object>(obj); - - // keeps strong references - // obj = null; - - try { - JiemamyAssert.assertGc(ref); - fail(); - } catch (AssertionError e) { - // success - } - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/05/09 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.internal.test; + +import static org.junit.Assert.fail; + +import java.lang.ref.WeakReference; + +import org.junit.Test; + +/** + * {@link JiemamyAssert}のテストクラス。 + * + * <p>cf. http://d.hatena.ne.jp/ashigeru/20080506/1210092877</p> + * + * @author daisuke + */ +public class JiemamyAssertTest { + + /** + * Test method for {@link JiemamyAssert#assertGc(java.lang.ref.WeakReference)}. + */ + @Test + public void testAssertGc() { + Object obj = new String("Hello, world!"); + WeakReference<Object> ref = new WeakReference<Object>(obj); + + // keeps only weak references + obj = null; + + JiemamyAssert.assertGc(ref); + } + + /** + * Test method for {@link JiemamyAssert#assertGc(java.lang.ref.WeakReference)}. + */ + @Test + public void testAssertGcLeak() { + Object obj = new String("Hello, world!"); + WeakReference<Object> ref = new WeakReference<Object>(obj); + + // keeps strong references + // obj = null; + + try { + JiemamyAssert.assertGc(ref); + fail(); + } catch (AssertionError e) { + // success + } + } + +} Property changes on: zeus/trunk/jiemamy-test-helper/src/test/java/org/jiemamy/internal/test/JiemamyAssertTest.java ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: zeus/trunk/jiemamy-test-helper/src/test/resources/logback.xml =================================================================== --- zeus/trunk/jiemamy-test-helper/src/test/resources/logback.xml 2009-09-20 17:23:12 UTC (rev 3643) +++ zeus/trunk/jiemamy-test-helper/src/test/resources/logback.xml 2009-09-20 17:27:46 UTC (rev 3644) @@ -1,18 +1,18 @@ -<?xml version="1.0" encoding="UTF-8"?> -<configuration> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <Target>System.out</Target> - <layout class="ch.qos.logback.classic.PatternLayout"> - <Pattern>%d{HH:mm:ss.SSS z,JST} [%thread] %-5level %logger{36} - %msg%n</Pattern> - </layout> - </appender> - - <root> - <level value="WARN" /> - <appender-ref ref="STDOUT" /> - </root> - - <logger name="org.jiemamy.utils.enhancer"> - <level value="TRACE" /> - </logger> -</configuration> +<?xml version="1.0" encoding="UTF-8"?> +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <Target>System.out</Target> + <layout class="ch.qos.logback.classic.PatternLayout"> + <Pattern>%d{HH:mm:ss.SSS z,JST} [%thread] %-5level %logger{36} - %msg%n</Pattern> + </layout> + </appender> + + <root> + <level value="WARN" /> + <appender-ref ref="STDOUT" /> + </root> + + <logger name="org.jiemamy.utils.enhancer"> + <level value="TRACE" /> + </logger> +</configuration> Property changes on: zeus/trunk/jiemamy-test-helper/src/test/resources/logback.xml ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native