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


Java JSONArray.toCollection方法代码示例

本文整理汇总了Java中net.sf.json.JSONArray.toCollection方法的典型用法代码示例。如果您正苦于以下问题:Java JSONArray.toCollection方法的具体用法?Java JSONArray.toCollection怎么用?Java JSONArray.toCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.json.JSONArray的用法示例。


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

示例1: selectionsMade

import net.sf.json.JSONArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@EventHandlerMethod
public void selectionsMade(SectionInfo info, String selections)
{
	final List<SelectedResourceDetails> selectedResources = new ArrayList<SelectedResourceDetails>(
		JSONArray.toCollection(JSONArray.fromObject(selections), SelectedResourceDetails.class));
	final WebRepository repo = dialogState.getRepository();
	final WizardState state = repo.getState();
	final MyPagesHandlerModel model = getModel(info);
	for( SelectedResourceDetails resource : selectedResources )
	{
		final ItemId key = new ItemId(resource.getUuid(), resource.getVersion());

		// clone the HtmlAttachments AND the file system only attachments
		// folder
		final Item item = itemService.get(key);
		final List<HtmlAttachment> pgs = new UnmodifiableAttachments(item).getList(AttachmentType.HTML);
		for( HtmlAttachment oldPage : pgs )
		{
			final HtmlAttachment newPage = mypagesService.clonePage(state, item, oldPage, true);
			if( Check.isEmpty(contrib.getPageUuid(info)) )
			{
				ChangePageEvent changePage = new ChangePageEvent(null, newPage.getUuid(), state.getWizid());
				info.processEvent(changePage, mypagesTree);
			}
			repo.getAttachments().addAttachment(newPage);
			// dialog.addAttachment(info, newPage);
		}
	}
	model.setSelecting(false);
}
 
开发者ID:equella,项目名称:Equella,代码行数:32,代码来源:MyPagesHandler.java

示例2: getListFromAttribute

import net.sf.json.JSONArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> List<T> getListFromAttribute(MimeEntry entry, String key, Class<T> entryType)
{
	Map<String, String> attr = entry.getAttributes();
	String jsonText = attr.get(key);
	if( !Check.isEmpty(jsonText) )
	{
		return new ArrayList<T>(JSONArray.toCollection(JSONArray.fromObject(jsonText), entryType));
	}
	return Collections.emptyList();
}
 
开发者ID:equella,项目名称:Equella,代码行数:13,代码来源:MimeTypeServiceImpl.java

示例3: executeDataMigration

import net.sf.json.JSONArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void executeDataMigration(HibernateMigrationHelper helper, MigrationResult result, Session session)
	throws Exception
{
	final List<MimeEntry> mimes = session.createQuery(FROM).list();
	for( MimeEntry mime : mimes )
	{
		final Map<String, String> attributes = mime.getAttributes();

		final String defaultViewer = attributes.get(MimeTypeConstants.KEY_DEFAULT_VIEWERID);
		if( !Check.isEmpty(defaultViewer) && defaultViewer.equals(VIEWER_ID) )
		{
			attributes.put(MimeTypeConstants.KEY_DEFAULT_VIEWERID, MimeTypeConstants.VAL_DEFAULT_VIEWERID);
		}

		final String enabledViewersJson = attributes.get(MimeTypeConstants.KEY_ENABLED_VIEWERS);
		if( !Check.isEmpty(enabledViewersJson) )
		{
			final List<String> viewers = new ArrayList<String>(JSONArray.toCollection(
				JSONArray.fromObject(enabledViewersJson), String.class));
			viewers.remove(VIEWER_ID);
			attributes.put(MimeTypeConstants.KEY_ENABLED_VIEWERS, JSONArray.fromObject(viewers).toString());
		}

		session.save(mime);
		session.flush();
		session.clear();

		result.incrementStatus();
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:33,代码来源:RemovePopupFixViewerDatabaseMigration.java

示例4: executeDataMigration

import net.sf.json.JSONArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void executeDataMigration(HibernateMigrationHelper helper, MigrationResult result, Session session)
{
	// Add ogg/webm if don't exist
	List<FakeInstitution> institutions = session.createQuery("FROM Institution").list();
	for( FakeInstitution inst : institutions )
	{
		if( count(session.createQuery(COUNT_OGG).setParameter("institution", inst)) == 0 )
		{
			FakeMimeEntry ogg = new FakeMimeEntry();
			ogg.setInstitution(inst);
			ogg.setType("video/ogg");
			ogg.addExtensions("ogv", "ogg");
			ogg.setDescription("Video");

			session.save(ogg);
		}
		if (count(session.createQuery(COUNT_WEBM).setParameter("institution", inst)) == 0)
		{
			FakeMimeEntry webm = new FakeMimeEntry();
			webm.setInstitution(inst);
			webm.setType("video/webm");
			webm.addExtensions("webm");
			webm.setDescription("Video");
			
			session.save(webm);
		}

		// Default Viewer option
		final List<FakeMimeEntry> entries = session.createQuery(FROM).setParameter("institution", inst).list();
		for( FakeMimeEntry entry : entries )
		{
			final Map<String, String> attributes = entry.attributes;
			attributes.put(MimeTypeConstants.KEY_DEFAULT_VIEWERID, HTML_FIVE_VIEWER_ID);
			final String enabledViewersJson = attributes.get(MimeTypeConstants.KEY_ENABLED_VIEWERS);
			final List<String> viewers;
			if( Check.isEmpty(enabledViewersJson) )
			{
				viewers = new ArrayList<String>();
			}
			else
			{
				viewers = new ArrayList<String>(JSONArray.toCollection(JSONArray.fromObject(enabledViewersJson),
					String.class));
			}
			viewers.add(HTML_FIVE_VIEWER_ID);
			attributes.put(MimeTypeConstants.KEY_ENABLED_VIEWERS, JSONArray.fromObject(viewers).toString());
			attributes.put(MimeTypeConstants.KEY_ICON_PLUGINICON, "icons/video.png");
			session.update(entry);

		}
		result.incrementStatus();
	}
	session.flush();
	session.clear();
}
 
开发者ID:equella,项目名称:Equella,代码行数:58,代码来源:HtmlFiveMimeTypeAndPlayerMigration.java

示例5: executeDataMigration

import net.sf.json.JSONArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void executeDataMigration(HibernateMigrationHelper helper, MigrationResult result, Session session)
	throws Exception
{
	final List<FakeMimeEntry> entries = session.createQuery(FROM).list();
	for( FakeMimeEntry entry : entries )
	{
		final Map<String, String> attributes = entry.attributes;
		final String defaultViewer = attributes.get(MimeTypeConstants.KEY_DEFAULT_VIEWERID);
		if( defaultViewer.equals(OLD_VIEWER_ID) )
		{
			attributes.put(MimeTypeConstants.KEY_DEFAULT_VIEWERID, NEW_VIEWER_ID);
		}

		final String enabledViewersJson = attributes.get(MimeTypeConstants.KEY_ENABLED_VIEWERS);
		if( !Check.isEmpty(enabledViewersJson) )
		{
			final List<String> viewers = new ArrayList<String>(JSONArray.toCollection(
				JSONArray.fromObject(enabledViewersJson), String.class));
			final int oldViewerIndex = viewers.indexOf(OLD_VIEWER_ID);
			if( oldViewerIndex >= 0 )
			{
				viewers.set(oldViewerIndex, NEW_VIEWER_ID);
				attributes.put(MimeTypeConstants.KEY_ENABLED_VIEWERS, JSONArray.fromObject(viewers).toString());
			}
		}

		session.update(entry);
		session.flush();

		result.incrementStatus();
	}

	final List<FakeAttachment> attachments = session.createQuery(FROM_ATTACHMENTS).list();
	for( FakeAttachment attachment : attachments )
	{
		attachment.viewer = NEW_VIEWER_ID;
		session.update(attachment);
		session.flush();

		result.incrementStatus();
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:45,代码来源:PrettyPhotoToFancyBoxDatabaseMigration.java


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