本文整理汇总了Java中org.simpleframework.xml.transform.RegistryMatcher.bind方法的典型用法代码示例。如果您正苦于以下问题:Java RegistryMatcher.bind方法的具体用法?Java RegistryMatcher.bind怎么用?Java RegistryMatcher.bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.simpleframework.xml.transform.RegistryMatcher
的用法示例。
在下文中一共展示了RegistryMatcher.bind方法的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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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());
}
}
示例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());
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
}
示例10: 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);
}
示例11: 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;
}
示例12: 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());
}
示例13: 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);
}
}
示例14: 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);
}
示例15: importConfigs
import org.simpleframework.xml.transform.RegistryMatcher; //导入方法依赖的package包/类
private void importConfigs(File f) throws Exception {
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
RegistryMatcher matcher = new RegistryMatcher();
Serializer serializer = new Persister(strategy, matcher);
matcher.bind(Long.class, LongTransform.class);
registry.bind(Date.class, DateConverter.class);
registry.bind(User.class, new UserConverter(userDao, userMap));
List<Configuration> list = readList(serializer, f, "configs.xml", "configs", Configuration.class);
for (Configuration c : list) {
if (c.getKey() == null || c.isDeleted()) {
continue;
}
String newKey = outdatedConfigKeys.get(c.getKey());
if (newKey != null) {
c.setKey(newKey);
}
Configuration.Type type = configTypes.get(c.getKey());
if (type != null) {
c.setType(type);
if (Configuration.Type.bool == type) {
c.setValue(String.valueOf("1".equals(c.getValue()) || "yes".equals(c.getValue()) || "true".equals(c.getValue())));
}
}
Configuration cfg = cfgDao.forceGet(c.getKey());
if (cfg != null && !cfg.isDeleted()) {
log.warn("Non deleted configuration with same key is found! old value: {}, new value: {}", cfg.getValue(), c.getValue());
}
c.setId(cfg == null ? null : cfg.getId());
if (c.getUser() != null && c.getUser().getId() == null) {
c.setUser(null);
}
if (CONFIG_CRYPT.equals(c.getKey())) {
try {
Class<?> clazz = Class.forName(c.getValue());
clazz.getDeclaredConstructor().newInstance();
} catch (Exception e) {
log.warn("Not existing Crypt class found {}, replacing with SCryptImplementation", c.getValue());
c.setValue(SCryptImplementation.class.getCanonicalName());
}
}
cfgDao.update(c, null);
}
}