当前位置: 首页>>代码示例>>Java>>正文


Java ObjectContainer类代码示例

本文整理汇总了Java中com.db4o.ObjectContainer的典型用法代码示例。如果您正苦于以下问题:Java ObjectContainer类的具体用法?Java ObjectContainer怎么用?Java ObjectContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ObjectContainer类属于com.db4o包,在下文中一共展示了ObjectContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteStudent

import com.db4o.ObjectContainer; //导入依赖的package包/类
/**
 * Delete student.
 *
 * @param studentID
 *            the student id
 * @param hostName
 *            the host name
 */
public static void deleteStudent(String studentID, String hostName)
{
	ObjectContainer db = Db4oClientServer.openClient(generateConfig(), hostName, Database.DB_PORT, Database.DB_USER, Database.DB_PASS);
	try
	{
		List<StudentDatabaseFormat> dbReps = db.query(StudentDatabaseFormat.class);
		if (dbReps != null)
		{
			for (StudentDatabaseFormat dbRep : dbReps)
			{
				if (dbRep.getStudentID().equals(studentID))
				{
					db.delete(dbRep);
					break;
				}
			}
		}
	}
	finally
	{
		db.close();
	}
}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:32,代码来源:DatabaseActivity.java

示例2: getStudentColour

import com.db4o.ObjectContainer; //导入依赖的package包/类
/**
 * Gets the student colour.
 *
 * @param studentID
 *            the student id
 * @param hostName
 *            the host name
 * @return the student colour
 */
public static String getStudentColour(String studentID, String hostName)
{
	ObjectContainer db = Db4oClientServer.openClient(generateConfig(), hostName, Database.DB_PORT, Database.DB_USER, Database.DB_PASS);
	try
	{
		List<StudentDatabaseFormat> dbReps = db.query(StudentDatabaseFormat.class);
		if (dbReps.size() > 0)
		{
			for (StudentDatabaseFormat dbRep : dbReps)
			{
				if (dbRep.getStudentID().equals(studentID))
				{
					return dbRep.getColour();
				}
			}
		}
	}
	finally
	{
		db.close();
	}
	return "white";
}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:33,代码来源:DatabaseActivity.java

示例3: getStudentGallery

import com.db4o.ObjectContainer; //导入依赖的package包/类
/**
 * Gets the student gallery.
 *
 * @param studentID
 *            the student id
 * @param hostName
 *            the host name
 * @return the student gallery
 */
public static ArrayList<GalleryItemDatabaseFormat> getStudentGallery(String studentID, String hostName)
{
	ObjectContainer db = Db4oClientServer.openClient(generateConfig(), hostName, Database.DB_PORT, Database.DB_USER, Database.DB_PASS);
	try
	{
		List<StudentDatabaseFormat> dbReps = db.query(StudentDatabaseFormat.class);
		if (dbReps.size() > 0)
		{
			for (StudentDatabaseFormat dbRep : dbReps)
			{
				if (dbRep.getStudentID().equals(studentID))
				{
					return dbRep.getGalleryItems();
				}
			}
		}
	}
	finally
	{
		db.close();
	}
	return new ArrayList<GalleryItemDatabaseFormat>();
}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:33,代码来源:DatabaseActivity.java

示例4: getStudentRepresentationFromDatabase

import com.db4o.ObjectContainer; //导入依赖的package包/类
/**
 * Gets the student representation from database.
 *
 * @param studentID
 *            the student id
 * @param hostName
 *            the host name
 * @param stage
 *            the stage
 * @return the student representation from database
 */
public static StudentRepresentation getStudentRepresentationFromDatabase(final String studentID, String hostName, IStage stage)
{
	ObjectContainer db = Db4oClientServer.openClient(generateConfig(), hostName, Database.DB_PORT, Database.DB_USER, Database.DB_PASS);
	try
	{

		List<StudentDatabaseFormat> dbReps = db.query(StudentDatabaseFormat.class);
		if (dbReps.size() > 0)
		{
			for (StudentDatabaseFormat dbRep : dbReps)
			{
				if (dbRep.getStudentID().equals(studentID))
				{
					StudentRepresentation studentRep = dbToStudentRep(dbRep, stage);
					return studentRep;
				}
			}
		}
	}
	finally
	{
		db.close();
	}
	return null;
}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:37,代码来源:DatabaseActivity.java

示例5: getStudentsFromDatabase

import com.db4o.ObjectContainer; //导入依赖的package包/类
/**
 * Gets the students from database.
 *
 * @param hostName
 *            the host name
 * @return the students from database
 */
public static ArrayList<Student> getStudentsFromDatabase(String hostName)
{
	ArrayList<Student> toReturn = new ArrayList<Student>();
	ObjectContainer db = Db4oClientServer.openClient(generateConfig(), hostName, Database.DB_PORT, Database.DB_USER, Database.DB_PASS);
	try
	{
		List<StudentDatabaseFormat> dbReps = db.query(StudentDatabaseFormat.class);

		if (dbReps.size() > 0)
		{
			for (StudentDatabaseFormat dbRep : dbReps)
			{
				Student student = dbToStudent(dbRep);
				toReturn.add(student);
			}
		}
	}
	finally
	{
		db.close();
	}
	return toReturn;
}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:31,代码来源:DatabaseActivity.java

示例6: moveStudent

import com.db4o.ObjectContainer; //导入依赖的package包/类
/**
 * Move student.
 *
 * @param studentID
 *            the student id
 * @param newClass
 *            the new class
 * @param hostName
 *            the host name
 */
public static void moveStudent(String studentID, String newClass, String hostName)
{
	ObjectContainer db = Db4oClientServer.openClient(generateConfig(), hostName, Database.DB_PORT, Database.DB_USER, Database.DB_PASS);
	try
	{
		List<StudentDatabaseFormat> dbReps = db.query(StudentDatabaseFormat.class);
		if (dbReps.size() > 0)
		{
			for (StudentDatabaseFormat dbRep : dbReps)
			{
				if (dbRep.getStudentID().equals(studentID))
				{
					dbRep.setClassname(newClass);
					db.delete(dbRep);
					db.store(dbRep);
					break;
				}
			}
		}
	}
	finally
	{
		db.close();
	}
}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:36,代码来源:DatabaseActivity.java

示例7: removeStudentsOfClass

import com.db4o.ObjectContainer; //导入依赖的package包/类
/**
 * Removes the students of class.
 *
 * @param className
 *            the class name
 * @param hostName
 *            the host name
 */
public static void removeStudentsOfClass(String className, String hostName)
{
	ObjectContainer db = Db4oClientServer.openClient(generateConfig(), hostName, Database.DB_PORT, Database.DB_USER, Database.DB_PASS);
	try
	{
		List<StudentDatabaseFormat> dbReps = db.query(StudentDatabaseFormat.class);
		if (dbReps != null)
		{
			for (StudentDatabaseFormat dbRep : dbReps)
			{
				if (dbRep.getClassName().equalsIgnoreCase(className))
				{
					db.delete(dbRep);
				}
			}
		}
	}
	finally
	{
		db.close();
	}
}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:31,代码来源:DatabaseActivity.java

示例8: createConnection

import com.db4o.ObjectContainer; //导入依赖的package包/类
private ObjectContainer createConnection() {
    try {

        EmbeddedConfiguration config = Db4oEmbedded.newConfiguration();
        config.common().add(new TransparentPersistenceSupport());
        //Controls the number of objects in memory
        config.common().activationDepth(Integer.MAX_VALUE);
        //Controls the depth/level of updation of Object
        config.common().updateDepth(Integer.MAX_VALUE);

        //Register your top most Class here
        config.common().objectClass(CentralAuthority.class).cascadeOnUpdate(true); // Change to the object you want to save

        ObjectContainer db = Db4oEmbedded.openFile(config, FILENAME);
        return db;
    } catch (Exception ex) {
        System.out.print(ex.getMessage());
    }
    return null;
}
 
开发者ID:abhishek-nandgaonkar,项目名称:HealTech,代码行数:21,代码来源:DB4OUtil.java

示例9: retrieveSystem

import com.db4o.ObjectContainer; //导入依赖的package包/类
public CentralAuthority retrieveSystem()
    {
        ObjectContainer conn = createConnection();
        ObjectSet<CentralAuthority> systems = conn.query(CentralAuthority.class); // Change to the object you want to save
        CentralAuthority system;
        if (systems.size() == 0){
            
            //system = CentralAuthority.getInstance();
            system = ConfigureCentralAuthority.initialize();
// If there's no System in the record, create a new one
            
        }
        else{
            //system = systems.get(0);
            system = systems.get(systems.size() - 1);
        }
        conn.close();
        return system;
    }
 
开发者ID:abhishek-nandgaonkar,项目名称:HealTech,代码行数:20,代码来源:DB4OUtil.java

示例10: clearSystem

import com.db4o.ObjectContainer; //导入依赖的package包/类
public synchronized void clearSystem()
{
    ObjectContainer conn = createConnection();
    ObjectSet<CentralAuthority> systems = conn.query(CentralAuthority.class); // Change to the object you want to save
    CentralAuthority system;
    if (systems.size() == 0){
        system = ConfigureCentralAuthority.initialize();  // If there's no System in the record, create a new one
        
    }
    else{
        system = systems.get(0);
    }
    conn.delete(system);
    conn.close();
    
}
 
开发者ID:abhishek-nandgaonkar,项目名称:HealTech,代码行数:17,代码来源:DB4OUtil.java

示例11: registerEventOnContainer

import com.db4o.ObjectContainer; //导入依赖的package包/类
/**
* 采用底层事件触发callBack机制自动实现AutoIncrement id的支持
* 使用方法:bean实例只需继承IDHolder类,即可自动增加一个自增的id字段
* @param 
* @return void
* @throws 
* 2013-9-4 下午02:54:44
*/
   public void registerEventOnContainer(final ObjectContainer container) {
       // #example: use events to assign the ids
       final AutoIncrement increment = new AutoIncrement(container);
       EventRegistry eventRegistry = EventRegistryFactory.forObjectContainer(container);
       eventRegistry.creating().addListener(new EventListener4<CancellableObjectEventArgs>() {
           public void onEvent(Event4<CancellableObjectEventArgs> event4,
                               CancellableObjectEventArgs objectArgs) {
               if(objectArgs.object() instanceof IDHolder){
                   IDHolder idHolder = (IDHolder) objectArgs.object();
                   idHolder.setId(increment.getNextID(idHolder.getClass()));
               }
           }
       });
       eventRegistry.committing().addListener(new EventListener4<CommitEventArgs>() {
           public void onEvent(Event4<CommitEventArgs> commitEventArgsEvent4,
                               CommitEventArgs commitEventArgs) {
               increment.storeState();
           }
       });
       // #end example
   }
 
开发者ID:hblt-j,项目名称:xmvc-for-android,代码行数:30,代码来源:DB4OHelper.java

示例12: save

import com.db4o.ObjectContainer; //导入依赖的package包/类
public void save(T obj) {
	if (obj == null) {
		return;
	}

	synchronized (DB4OUtils.class) {

		ObjectContainer oc = Db4oEmbedded.openFile(DB4OUtils
				.getDataBasePath());
		try {

			oc.store(obj);
			oc.commit();
			
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			oc.close();
		}
	}
}
 
开发者ID:yukozh,项目名称:CodeComb.Mobile.Android,代码行数:23,代码来源:BaseProvider.java

示例13: getKeys

import com.db4o.ObjectContainer; //导入依赖的package包/类
@Override
public Collection<Integer> getKeys() throws StorageOperationException {
	ObjectContainer db = Db4oEmbedded.openFile(getConfiguration(), source);

	final Collection<Integer> result = new ArrayList<Integer>();

	try {
		db.query(new Predicate<V>() {
			@Override
			public boolean match(V v) {
				result.add(v.hashCode());
				return false;
			}
		});

	} finally {
		db.close();
	}

	return result;
}
 
开发者ID:kboom,项目名称:setphrase,代码行数:22,代码来源:DB4oObjectStorage.java

示例14: getAll

import com.db4o.ObjectContainer; //导入依赖的package包/类
@Override
public List<V> getAll(final K... keys) throws StorageOperationException {
	ObjectContainer db = Db4oEmbedded.openFile(getConfiguration(), source);

	List<V> result = null;
	try {
		result = db.query(new Predicate<V>() {
			@Override
			public boolean match(V v) {
				for (K key : keys) {
					if (key.match(v))
						return true;
				}
				return false;
			}
		});

	} finally {
		db.close();
	}
	if (result == null)
		return createList();
	else
		return result;
}
 
开发者ID:kboom,项目名称:setphrase,代码行数:26,代码来源:DB4oObjectStorage.java

示例15: put

import com.db4o.ObjectContainer; //导入依赖的package包/类
@Override
public void put(final K key, V value) throws StorageOperationException {
	ObjectContainer db = Db4oEmbedded.openFile(getConfiguration(), source);
	ObjectSet<V> set = db.query(new Predicate<V>() {
		@Override
		public boolean match(V v) {
			if (key.match(v))
				return true;
			else
				return false;
		}
	});
	db.delete(set);
	db.store(value);
	db.close();
}
 
开发者ID:kboom,项目名称:setphrase,代码行数:17,代码来源:DB4oObjectStorage.java


注:本文中的com.db4o.ObjectContainer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。