diff options
author | Grzegorz Kossakowski <grek@google.com> | 2009-08-12 16:24:04 -0700 |
---|---|---|
committer | Grzegorz Kossakowski <grek@google.com> | 2009-08-12 17:34:57 -0700 |
commit | 4572469aaa322efbc907997c3969b262e90fb696 (patch) | |
tree | fed9470a3379f6066f485001eace0de5c6701f33 | |
parent | 07015a2f13198332e789fa5af5035b9569f2e42f (diff) | |
download | gimd-4572469aaa322efbc907997c3969b262e90fb696.tar.gz |
Introduce few abstract classes/traits: FileType, File and Database.
These abstract interfaces will provide all functionality needed by Gimd
to access actual datastore. Canonical implementation of these interfaces
will be provided on top of JGit.
Signed-off-by: Grzegorz Kossakowski <grek@google.com>
-rw-r--r-- | src/main/scala/com/google/gimd/Database.scala | 30 | ||||
-rw-r--r-- | src/main/scala/com/google/gimd/DatabaseException.scala | 18 | ||||
-rw-r--r-- | src/main/scala/com/google/gimd/file/File.scala | 33 | ||||
-rw-r--r-- | src/main/scala/com/google/gimd/file/FileType.scala | 38 |
4 files changed, 119 insertions, 0 deletions
diff --git a/src/main/scala/com/google/gimd/Database.scala b/src/main/scala/com/google/gimd/Database.scala new file mode 100644 index 0000000..668bdd2 --- /dev/null +++ b/src/main/scala/com/google/gimd/Database.scala @@ -0,0 +1,30 @@ +// Copyright (C) 2009 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gimd + +import file.{File, FileType} + +/** + * Trait that provides all functionality for Gimd to ask specific storage implementation + * for needed data in an efficient way. + */ +trait Database { + + /** + * @return iterator over collection of all Files that conform to passed FileType[T]. + */ + def all[T](fileType: FileType[T]): Iterator[File[T]] + +} diff --git a/src/main/scala/com/google/gimd/DatabaseException.scala b/src/main/scala/com/google/gimd/DatabaseException.scala new file mode 100644 index 0000000..d47ac31 --- /dev/null +++ b/src/main/scala/com/google/gimd/DatabaseException.scala @@ -0,0 +1,18 @@ +// Copyright (C) 2009 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gimd + +abstract class DatabaseException(message: String, cause: Throwable) + extends Exception(message, cause) diff --git a/src/main/scala/com/google/gimd/file/File.scala b/src/main/scala/com/google/gimd/file/File.scala new file mode 100644 index 0000000..4ac695e --- /dev/null +++ b/src/main/scala/com/google/gimd/file/File.scala @@ -0,0 +1,33 @@ +// Copyright (C) 2009 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gimd.file + +/** + * File is one of the fundamental concepts in Gimd. Basically File is unit of + * storage with path associated with it. + * + * Every file has exactly one FileType[T] associated and conforms to meta-data + * carried by FileType[T]. + * + * As consequence of association to FileType[T] single File[T] stores single message + * which is representation of type T. + */ +trait File[T] { + val path: String + val fileType: FileType[T] + val message: Message + val userObject: T + +} diff --git a/src/main/scala/com/google/gimd/file/FileType.scala b/src/main/scala/com/google/gimd/file/FileType.scala new file mode 100644 index 0000000..4ca2db1 --- /dev/null +++ b/src/main/scala/com/google/gimd/file/FileType.scala @@ -0,0 +1,38 @@ +// Copyright (C) 2009 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gimd.file + +/** + * FileType carries so meta-information about set of Files that conform to + * all information carried by FileType. + */ +abstract class FileType[T] { + + /** + * prefix of File's path or None if there's no common prefix. + */ + def pathPrefix: Option[String] + + /** + * suffix of File's path or None if there's no common suffix. + */ + def pathSuffix: Option[String] + + /** + * Type of information that File stores. + */ + def userType: UserType[T] + +} |