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


Java RegistryMatcher类代码示例

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


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

示例1: getReadSerializer

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
private static Serializer getReadSerializer() throws Exception {
	if (readSerializer == null) {
	Log.d("hv", "Begin Creating Serializer");
       RegistryMatcher matcher = new RegistryMatcher();
       matcher.bind(Date.class, new DateFormatTransformer());

       Registry registry = new Registry();
       registry.bind(String.class, SimpleXMLStringConverter.class);
       Strategy strategy = new RegistryStrategy(registry);

       Serializer s = new Persister(strategy, matcher);
	Log.d("hv", "Done Creating Serializer");
	
	readSerializer = s;
	}
       return readSerializer;
}
 
开发者ID:Microsoft,项目名称:healthvault-java-sdk,代码行数:18,代码来源:XmlSerializer.java

示例2: getFeedItems

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
private List<Item> getFeedItems(String feedUrl) throws Exception {
    ArrayList<Item> items = new ArrayList<>();
    Request request = new Request.Builder().url(feedUrl).get().build();
    Response response = client.newCall(request).execute();

    if (response.isSuccessful()) {
        String data = response.body().string();
        Timber.e("Got response from server: " + data);
        DateFormat rssDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
        RegistryMatcher registryMatcher = new RegistryMatcher();
        registryMatcher.bind(Date.class, new DateTransformer(rssDateFormat));
        Serializer serializer = new Persister(registryMatcher);
        final Rss rss = serializer.read(Rss.class,data);
        if (rss != null && rss.channel != null && rss.channel.items.size() > 0) {
            items.addAll(rss.channel.items);
        }
    }
    return items;
}
 
开发者ID:seguemodev,项目名称:Meducated-Ninja,代码行数:20,代码来源:NewsService.java

示例3: toXml

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
public ByteArrayOutputStream toXml(Object objectToSerialize) {
    try {
        RegistryMatcher matcher = new RegistryMatcher();
        matcher.bind(Boolean.class, BooleanSimpleXmlAdapter.class);
        matcher.bind(GregorianCalendar.class, CalendarSimpleXmlAdapter.class);
        matcher.bind(UUID.class, UUIDSimpleXmlAdapter.class);
        matcher.bind(byte[].class, ByteSimpleXmlAdapter.class);
        
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        TreeStrategyWithoutArrayLength strategy = new TreeStrategyWithoutArrayLength();
        Serializer serializer = new Persister(strategy, matcher);
        serializer.write(objectToSerialize, outputStream);
        return outputStream;
    }
    catch (Exception e) {
        throw new KeePassDatabaseUnwriteableException("Could not serialize object to xml", e);
    }
}
 
开发者ID:cternes,项目名称:openkeepass,代码行数:19,代码来源:SimpleXmlParser.java

示例4: getSerializer

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
/**
 * Retrieve a {@link Serializer} instance suitable for deserialising a
 * {@link ConfigurationReport}.
 *
 * @return a new {@link Serializer} instance
 */
private Serializer getSerializer() {
  DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
  RegistryMatcher matcher = new RegistryMatcher();
  matcher.bind(Timestamp.class, new DateFormatConverter(format));
  Strategy strategy = new AnnotationStrategy();
  Serializer serializer = new Persister(strategy, matcher);
  return serializer;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:15,代码来源:ConfigurationLoaderImpl.java

示例5: importRooms

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
private void importRooms(File f) throws Exception {
	log.info("Users import complete, starting room import");
	Registry registry = new Registry();
	Strategy strategy = new RegistryStrategy(registry);
	RegistryMatcher matcher = new RegistryMatcher();
	Serializer ser = new Persister(strategy, matcher);

	matcher.bind(Long.class, LongTransform.class);
	matcher.bind(Integer.class, IntegerTransform.class);
	registry.bind(User.class, new UserConverter(userDao, userMap));
	registry.bind(Room.Type.class, RoomTypeConverter.class);
	registry.bind(Date.class, DateConverter.class);
	List<Room> list = readList(ser, f, "rooms.xml", "rooms", Room.class);
	for (Room r : list) {
		Long roomId = r.getId();

		// We need to reset ids as openJPA reject to store them otherwise
		r.setId(null);
		if (r.getModerators() != null) {
			for (Iterator<RoomModerator> i = r.getModerators().iterator(); i.hasNext();) {
				RoomModerator rm = i.next();
				if (rm.getUser().getId() == null) {
					i.remove();
				}
			}
		}
		r = roomDao.update(r, null);
		roomMap.put(roomId, r.getId());
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:31,代码来源:BackupImport.java

示例6: importRecordings

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
private void importRecordings(File f) throws Exception {
	log.info("Meeting members import complete, starting recordings server import");
	Registry registry = new Registry();
	Strategy strategy = new RegistryStrategy(registry);
	RegistryMatcher matcher = new RegistryMatcher();
	Serializer ser = new Persister(strategy, matcher);

	matcher.bind(Long.class, LongTransform.class);
	matcher.bind(Integer.class, IntegerTransform.class);
	registry.bind(Date.class, DateConverter.class);
	registry.bind(Recording.Status.class, RecordingStatusConverter.class);
	List<Recording> list = readList(ser, f, "flvRecordings.xml", "flvrecordings", Recording.class);
	for (Recording r : list) {
		Long recId = r.getId();
		r.setId(null);
		if (r.getRoomId() != null) {
			r.setRoomId(roomMap.get(r.getRoomId()));
		}
		if (r.getOwnerId() != null) {
			r.setOwnerId(userMap.get(r.getOwnerId()));
		}
		if (r.getMetaData() != null) {
			for (RecordingMetaData meta : r.getMetaData()) {
				meta.setId(null);
				meta.setRecording(r);
			}
		}
		if (!Strings.isEmpty(r.getHash()) && r.getHash().startsWith(RECORDING_FILE_NAME)) {
			String name = getFileName(r.getHash());
			r.setHash(UUID.randomUUID().toString());
			fileMap.put(String.format(FILE_NAME_FMT, name, EXTENSION_JPG), String.format(FILE_NAME_FMT, r.getHash(), EXTENSION_PNG));
			fileMap.put(String.format("%s.%s.%s", name, EXTENSION_FLV, EXTENSION_MP4), String.format(FILE_NAME_FMT, r.getHash(), EXTENSION_MP4));
		}
		if (Strings.isEmpty(r.getHash())) {
			r.setHash(UUID.randomUUID().toString());
		}
		r = recordingDao.update(r);
		fileItemMap.put(recId, r.getId());
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:41,代码来源:BackupImport.java

示例7: importFiles

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
private List<FileItem> importFiles(File f) throws Exception {
	log.info("Private message import complete, starting file explorer item import");
	List<FileItem> result = new ArrayList<>();
	Registry registry = new Registry();
	Strategy strategy = new RegistryStrategy(registry);
	RegistryMatcher matcher = new RegistryMatcher();
	Serializer ser = new Persister(strategy, matcher);

	matcher.bind(Long.class, LongTransform.class);
	matcher.bind(Integer.class, IntegerTransform.class);
	registry.bind(Date.class, DateConverter.class);
	List<FileItem> list = readList(ser, f, "fileExplorerItems.xml", "fileExplorerItems", FileItem.class);
	for (FileItem file : list) {
		Long fId = file.getId();
		// We need to reset this as openJPA reject to store them otherwise
		file.setId(null);
		Long roomId = file.getRoomId();
		file.setRoomId(roomMap.containsKey(roomId) ? roomMap.get(roomId) : null);
		if (file.getOwnerId() != null) {
			file.setOwnerId(userMap.get(file.getOwnerId()));
		}
		if (file.getParentId() != null && file.getParentId().longValue() <= 0L) {
			file.setParentId(null);
		}
		if (Strings.isEmpty(file.getHash())) {
			file.setHash(UUID.randomUUID().toString());
		}
		file = fileItemDao.update(file);
		result.add(file);
		fileItemMap.put(fId, file.getId());
	}
	return result;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:34,代码来源:BackupImport.java

示例8: importPolls

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
private void importPolls(File f) throws Exception {
	log.info("File explorer item import complete, starting room poll import");
	Registry registry = new Registry();
	Strategy strategy = new RegistryStrategy(registry);
	RegistryMatcher matcher = new RegistryMatcher();
	Serializer serializer = new Persister(strategy, matcher);

	matcher.bind(Integer.class, IntegerTransform.class);
	registry.bind(User.class, new UserConverter(userDao, userMap));
	registry.bind(Room.class, new RoomConverter(roomDao, roomMap));
	registry.bind(RoomPoll.Type.class, PollTypeConverter.class);
	registry.bind(Date.class, DateConverter.class);

	List<RoomPoll> list = readList(serializer, f, "roompolls.xml", "roompolls", RoomPoll.class);
	for (RoomPoll rp : list) {
		rp.setId(null);
		if (rp.getRoom() == null || rp.getRoom().getId() == null) {
			//room was deleted
			continue;
		}
		if (rp.getCreator() == null || rp.getCreator().getId() == null) {
			rp.setCreator(null);
		}
		for (RoomPollAnswer rpa : rp.getAnswers()) {
			if (rpa.getVotedUser() == null || rpa.getVotedUser().getId() == null) {
				rpa.setVotedUser(null);
			}
		}
		pollDao.update(rp);
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:32,代码来源:BackupImport.java

示例9: addTransformers

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
private static void addTransformers(@Nonnull RegistryMatcher matcher, @Nonnull Serializer serializer, @Nonnull Iterable<? extends TransformFactory> factories) {
    for (TransformFactory factory : factories) {
        // LOG.info("Factory " + factory);
        for (Map.Entry<? extends Class<?>, ? extends Transform<?>> e : factory.newTransforms()) {
            // LOG.info("Register " + e.getKey() + " -> " + e.getValue());
            try {
                matcher.bind(e.getKey(), e.getValue());
            } catch (Exception ex) {
                LOG.error("Failed to bind " + e.getKey() + " to " + e.getValue(), ex);
            }
        }
    }
}
 
开发者ID:shevek,项目名称:simple-xml-serializers,代码行数:14,代码来源:PersisterFactory.java

示例10: newRegistryMatcher

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
@Nonnull
private static RegistryMatcher newRegistryMatcher() {
    RegistryMatcher matcher = new RegistryMatcher() {
        @Override
        public Transform match(Class type) throws Exception {
            if (Type.class.isAssignableFrom(type))
                return TypeTransform.getInstance();
            return super.match(type);
        }
    };
    return matcher;
}
 
开发者ID:shevek,项目名称:simple-xml-serializers,代码行数:13,代码来源:TypeConverterTest.java

示例11: getPersister

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
@Provides
Persister getPersister() {
    RegistryMatcher matchers = new RegistryMatcher();
    matchers.bind(org.joda.time.DateTime.class, JodaTimeDateTimeTransform.class);

    Strategy strategy = new AnnotationStrategy();
    return new Persister(strategy, matchers);
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:9,代码来源:CommonSyncModule.java

示例12: createSerializer

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
private Serializer createSerializer() {
    RegistryMatcher matcher = new RegistryMatcher();
    matcher.bind(Boolean.class, BooleanSimpleXmlAdapter.class);
    matcher.bind(GregorianCalendar.class, CalendarSimpleXmlAdapter.class);
    matcher.bind(UUID.class, UUIDSimpleXmlAdapter.class);
    matcher.bind(byte[].class, ByteSimpleXmlAdapter.class);
    
    TreeStrategyWithoutArrayLength strategy = new TreeStrategyWithoutArrayLength();
    Serializer serializer = new Persister(strategy, matcher);
    return serializer;
}
 
开发者ID:cternes,项目名称:openkeepass,代码行数:12,代码来源:SimpleXmlParser.java

示例13: main

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
/**
 * Test starting point
 * 
 * @param args
 * @throws Exception
 */
public static void main(String args[]) throws Exception {
    System.out.println("Start: " + new Date());
    
    String filePath = System.getProperty("user.home") + "/SimpleObjectTest/web.xml";
    if(args.length > 0) {
        filePath = args[0];
    }
    RegistryMatcher matcher = new RegistryMatcher();
    matcher.bind(ErrorCodeType.class, ErrorCodeTypeTransform.class);
    matcher.bind(ExceptionTypeType.class, ExceptionTypeTypeTransform.class);
    matcher.bind(ServletClassType.class, ServletClassTypeTransform.class);
    matcher.bind(JspFileType.class, JspFileTypeTransform.class);
    matcher.bind(UrlPatternType.class, UrlPatternTypeTransform.class);
    matcher.bind(ServletNameType.class, ServletNameTypeTransform.class);
    Serializer serializer = new Persister(matcher, new Format(4, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));

    WebApp webApp = new WebApp(getIcon(), getDisplayName(), getDescription(), getDistributable(), 
            getContextParams(), getFilters(), getFilterMappings(), getListeners(), getServlets(), 
            getServletMappings(), getSessionConfig(), getMimeMappings(), getWelcomeFileList(), 
            getErrorPages(), getTaglibs(), getResourceEnvRefs(), getResourceRefs(), 
            getSecurityConstraints(), getLoginConfig(), getSecurityRoles(), getEnvEntrys(), 
            getEjbRefs(), getEjbLocalRefs());

    serializer.write(webApp, new OutputStreamWriter(new FileOutputStream(filePath), "UTF-8"));

    System.out.println("  End: " + new Date());
}
 
开发者ID:markbernard,项目名称:commonsimplexml,代码行数:34,代码来源:WebAppTest.java

示例14: XmlSerializer

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
public XmlSerializer(Class<T> classe) {
	classType = classe;
	try {
		RegistryMatcher m = new RegistryMatcher();
		m.bind(byte[].class, new ByteArrayTransformer());
		marshaller = new Persister(m);
	} catch (Exception ex) {
		throw new RuntimeException("Cannot instantiate JaxbSerializer for class: " + classType.getName(), ex);
	}
}
 
开发者ID:biosignin,项目名称:bsi-core,代码行数:11,代码来源:XmlSerializer.java

示例15: performImport

import org.simpleframework.xml.transform.RegistryMatcher; //导入依赖的package包/类
public void performImport(InputStream is) throws Exception {
	userMap.clear();
	groupMap.clear();
	calendarMap.clear();
	appointmentMap.clear();
	roomMap.clear();
	messageFolderMap.clear();
	userContactMap.clear();
	fileMap.clear();
	messageFolderMap.put(INBOX_FOLDER_ID, INBOX_FOLDER_ID);
	messageFolderMap.put(SENT_FOLDER_ID, SENT_FOLDER_ID);
	messageFolderMap.put(TRASH_FOLDER_ID, TRASH_FOLDER_ID);

	File f = unzip(is);
	Registry registry = new Registry();
	Strategy strategy = new RegistryStrategy(registry);
	RegistryMatcher matcher = new RegistryMatcher();
	Serializer simpleSerializer = new Persister(strategy, matcher);

	matcher.bind(Long.class, LongTransform.class);
	registry.bind(Date.class, DateConverter.class);

	BackupVersion ver = getVersion(simpleSerializer, f);
	importConfigs(f);
	importGroups(f, simpleSerializer);
	Long defaultLdapId = importLdap(f, simpleSerializer);
	importOauth(f, simpleSerializer);
	importUsers(f, defaultLdapId);
	importRooms(f);
	importRoomGroups(f);
	importChat(f);
	importCalendars(f);
	importAppointments(f);
	importMeetingMembers(f);
	importRecordings(f);
	importPrivateMsgFolders(f, simpleSerializer);
	importContacts(f);
	importPrivateMsgs(f);
	List<FileItem> files = importFiles(f);
	importPolls(f);
	importRoomFiles(f);

	log.info("Room files import complete, starting copy of files and folders");
	/*
	 * ##################### Import real files and folders
	 */
	importFolders(f);

	if (ver.compareTo(BackupVersion.get("4.0.0")) < 0) {
		for (BaseFileItem bfi : files) {
			if (bfi.isDeleted()) {
				continue;
			}
			if (BaseFileItem.Type.Presentation == bfi.getType()) {
				convertOldPresentation((FileItem)bfi);
				fileItemDao._update(bfi);
			}
			if (BaseFileItem.Type.WmlFile == bfi.getType()) {
				try {
					Whiteboard wb = WbConverter.convert((FileItem)bfi);
					wb.save(bfi.getFile().toPath());
				} catch (Exception e) {
					log.error("Unexpected error while converting WB", e);
				}
			}
		}
	}
	log.info("File explorer item import complete, clearing temp files");

	FileUtils.deleteDirectory(f);
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:72,代码来源:BackupImport.java


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