Content subjContent = new Content().withData("Test of Amazon SES"); Message msg = new Message().withSubject(subjContent); // Include a body in both text and HTML formats Content textContent = new Content().withData("Hello - I hope you're having a good day."); Content htmlContent = new Content().withData("<h1>Hello - I hope you're having a good day.</h1>"); Body body = new Body().withHtml(htmlContent).withText(textContent); msg.setBody(body);
public Content unmarshall(StaxUnmarshallerContext context) throws Exception { Content content = new Content(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return content; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Data", targetDepth)) { content.setData(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Charset", targetDepth)) { content.setCharset(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return content; } } } }
import java.util.*; import javax.xml.bind.*; public class Demo { public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Content.class); List<String> strings = new ArrayList<String>(2); strings.add("foo"); strings.add("bar"); Content content = new Content(); content.setKeywords(strings); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(content, System.out); } }
[DisableCache] public ActionResult YourMethod() { return new Content("This is not cached"); }
<? include_once("php/functions.php"); $cont = new Content(); echo ($cont->getPosts()); ?>
public class Applet1 extends JApplet { public void init() { add(new Content()); } }
onRender: function() { MyView.prototype.onRender(this); // extra content for my SecondView goes here... var secondViewContent = new Content(); this.someRegionInMyView.show(secondViewContent); }
MyClass m = mock(MyClass.class); when(m.createChild(any(String.class), any(String.class), any(Map.class))).thenReturn(new Content());
public class CustomNamingStrategy extends PropertyNamingStrategyBase { @Override public String translate(String propertyName) { // find a naming strategy here return propertyName; } } ObjectMapper om = new ObjectMapper(); Pojo myPojo = new Pojo(1, 10, new Content("string", "sid")); om.setPropertyNamingStrategy(new CustomNamingStrategy()); System.out.print(om.writerWithDefaultPrettyPrinter().writeValueAsString(myPojo));
Observable .from(cm.getPermalinks(10)) .flatMap(permalink -> Observable.zip( Observable.<Content>create(subscriber -> cm.getDataByPermalink(permalink, new SubscribingRestCallback(subscriber))), Observable.<Content>create(subscriber -> cm.getStreamByPermalink(permalink, new SubscribingRestCallback(subscriber))), (dataContent, streamUrlContent) -> { return new Content(dataContent.permalink, dataContent.logoUrl, streamUrlContent.streamUrl); }).onErrorResumeNext(Observable.empty())) .subscribe(System.out::println);
public Result toResult() { Content ret = null; try { final String jsonpayload = new ObjectMapper().writerWithView(JsonViews.Public.class).writeValueAsString(payload); ret = new Content() { @Override public String body() { return jsonpayload; } @Override public String contentType() { return "application/json"; } }; } catch (JsonProcessingException exc) { Logger.error("toResult: ", exc); } if (ret == null) return Results.badRequest(); return Results.ok(ret); }
val conf = NutchConfiguration.create() val fs = FileSystem.get(conf) val file = new Path(".../part-00000/data") val reader = new SequenceFile.Reader(fs, file, conf) val webdata = Stream.continually { val key = new Text() val content = new Content() reader.next(key, content) (key, content) } println(webdata.head)
public Content unmarshall(StaxUnmarshallerContext context) throws Exception { Content content = new Content(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) break; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("Data", targetDepth)) { content.setData(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Charset", targetDepth)) { content.setCharset(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return content; }
public static void sendEmail(String receiver,String title,String message){ AWSCredentials credentials = getCreds(); AmazonSimpleEmailServiceClient sesClient = new AmazonSimpleEmailServiceClient( credentials ); Content subjectContent = new Content(title); Body messageBody = new Body(new Content(message)); Message feedbackMessage = new Message(subjectContent,messageBody); Destination destination = new Destination().withToAddresses(receiver); SendEmailRequest request = new SendEmailRequest(receiver,destination,feedbackMessage); SendEmailResult result = sesClient.sendEmail(request); }
when(m.createChild(any(String.class), any(String.class), any(Map.class))).thenAnswer( new Answer<Content>() { @Override public Content answer(final InvocationOnMock invocation) throws Throwable { return new Content((String) invocation.getArguments()[0], (String) invocation.getArguments()[1], (Map) invocation.getArguments()[2]); } } } );
@Override public void send(String subject, String body, String... recipients) { Body requestBody = new Body().withText(new Content(body)); sendEmail(subject, requestBody, recipients); }
@Override public void sendAsHtml(String subject, String body, String... recipients) { Body requestBody = new Body().withHtml(new Content(body)); sendEmail(subject, requestBody, recipients); }
private Body bodyOfEmail(Email email) { if (email.getHtmlBody() != null) { Content htmlBody = new Content().withData(email.getHtmlBody()); return new Body().withHtml(htmlBody); } if (email.getTextBody() != null) { Content textBody = new Content().withData(email.getTextBody()); return new Body().withHtml(textBody); } return new Body(); }
private void sendEmail(String subject, Body body, String... recipients) { Destination destination = new Destination(Arrays.asList(recipients)); Message msg = new Message().withBody(body).withSubject(new Content(subject)); SendEmailRequest request = new SendEmailRequest().withSource(fromAddress) .withDestination(destination) .withMessage(msg); emailService.sendEmail(request); } }
@Override public boolean sendEmail(List<String> emails, String subject, String body) { if (emails != null && !emails.isEmpty() && !StringUtils.isBlank(body)) { final SendEmailRequest request = new SendEmailRequest().withSource(Config.SUPPORT_EMAIL); Destination dest = new Destination().withToAddresses(emails); request.setDestination(dest); Content subjContent = new Content().withData(subject); Message msg = new Message().withSubject(subjContent); // Include a body in both text and HTML formats Content textContent = new Content().withData(body).withCharset(Config.DEFAULT_ENCODING); msg.setBody(new Body().withHtml(textContent)); request.setMessage(msg); Utils.asyncExecute(new Runnable() { public void run() { sesclient.sendEmail(request); } }); return true; } return false; } }