use of org.mozilla.jss.asn1.Tag in project GeoGig by boundlessgeo.
the class OSMUtils method buildTagsCollectionFromString.
public static Collection<Tag> buildTagsCollectionFromString(String tagsString) {
Collection<Tag> tags = Lists.newArrayList();
if (tagsString != null) {
String[] tokens = tagsString.split("\\|");
for (String token : tokens) {
int idx = token.lastIndexOf(':');
if (idx != -1) {
Tag tag = new Tag(token.substring(0, idx), token.substring(idx + 1));
tags.add(tag);
} else {
LOGGER.info("found tag token '{}' with no value in tagString '{}'", token, tagsString);
}
}
}
return tags;
}
use of org.mozilla.jss.asn1.Tag in project requery by requery.
the class JacksonTest method testOneToManySerialize.
@Test
public void testOneToManySerialize() {
Event event = new Event();
UUID id = UUID.randomUUID();
event.setId(id);
event.setName("test");
Tag t1 = new Tag();
t1.setId(UUID.randomUUID());
Tag t2 = new Tag();
t2.setId(UUID.randomUUID());
event.getTags().add(t1);
event.getTags().add(t2);
Place p = new Place();
p.setId("SF");
p.setName("San Francisco, CA");
event.setPlace(p);
data.insert(event);
ObjectMapper mapper = new EntityMapper(Models.MODEL3, data);
StringWriter writer = new StringWriter();
try {
mapper.writeValue(writer, event);
} catch (IOException e) {
throw new RuntimeException(e);
}
String value = writer.toString();
System.out.println(value);
try {
Event read = mapper.readValue(value, Event.class);
assertSame(event, read);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.mozilla.jss.asn1.Tag in project requery by requery.
the class JacksonTest method testManyToManySerialize.
@Test
public void testManyToManySerialize() {
Tag t1 = new Tag();
t1.setId(UUID.randomUUID());
for (int i = 0; i < 3; i++) {
Event event = new Event();
UUID id = UUID.randomUUID();
event.setId(id);
event.setName("event" + i);
t1.getEvents().add(event);
}
data.insert(t1);
ObjectMapper mapper = new EntityMapper(Models.MODEL3, data);
StringWriter writer = new StringWriter();
try {
mapper.writeValue(writer, t1);
} catch (IOException e) {
throw new RuntimeException(e);
}
String value = writer.toString();
System.out.println(value);
try {
Tag tag = mapper.readValue(value, Tag.class);
assertSame(t1, tag);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.mozilla.jss.asn1.Tag in project requery by requery.
the class UpsertTest method testUpsertManyToMany.
@Test
public void testUpsertManyToMany() {
Event event1 = new Event();
event1.setId(UUID.randomUUID());
Tag tag = new Tag();
tag.setId(UUID.randomUUID());
tag.getEvents().add(event1);
data.upsert(tag);
Event event2 = new Event();
event2.setId(UUID.randomUUID());
tag.getEvents().add(event2);
data.upsert(event2);
data.upsert(tag);
}
use of org.mozilla.jss.asn1.Tag in project omegat by omegat-org.
the class Handler method translateButDontFlash.
/**
* One of the main methods of the XML filter: it collects all the data,
* adjusts it, and sends for translation.
*
* @see #translateAndFlush()
*/
private void translateButDontFlash() throws TranslationException {
if (currEntry().isEmpty()) {
return;
}
boolean isTranslated = true;
List<ProtectedPart> shortcutDetails = new ArrayList<ProtectedPart>();
boolean tagsAggregation = isTagsAggregationEnabled();
String src = currEntry().sourceToShortcut(tagsAggregation, dialect, shortcutDetails);
Element lead = currEntry().get(0);
String translation = src;
if ((lead instanceof Tag) && (isPreformattingTag(((Tag) lead).getTag(), ((Tag) lead).getAttributes()) || isSpacePreservingTag()) && isTranslatableTag() && !StringUtil.isEmpty(src)) {
resetSpacePreservingTag();
translation = translator.translate(src, shortcutDetails);
} else {
String compressed = src;
if (Core.getFilterMaster().getConfig().isRemoveSpacesNonseg()) {
compressed = StringUtil.compressSpaces(src);
}
if (isTranslatableTag()) {
translation = translator.translate(compressed, shortcutDetails);
}
// untranslated is written out uncompressed
if (compressed.equals(translation)) {
translation = src;
isTranslated = false;
}
}
if (lead instanceof XMLTag) {
dialect.handleXMLTag((XMLTag) lead, isTranslated);
}
currEntry().setTranslation(translation, dialect, new ArrayList<ProtectedPart>());
}
Aggregations