本文整理汇总了Java中com.evernote.edam.type.Note.setContent方法的典型用法代码示例。如果您正苦于以下问题:Java Note.setContent方法的具体用法?Java Note.setContent怎么用?Java Note.setContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.evernote.edam.type.Note
的用法示例。
在下文中一共展示了Note.setContent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNote
import com.evernote.edam.type.Note; //导入方法依赖的package包/类
/**
* Creates a new note
*
* @param title The note's title
* @param content The note's content as EHTML
* @param date If not null used for created and updated date
* @param source Source attribute to be added to the note
* @throws Exception
*/
public Note createNote(String title, String content, Long date, String source) throws Exception {
LOG.debug("Creating new note: {}", title);
Note note = new Note();
note.setTitle(title);
note.setContent(content);
if ( date != null) {
note.setCreated(date);
note.setUpdated(date);
}
if (source != null && source.length()>0) {
NoteAttributes attributes = new NoteAttributes();
attributes.setSource(source);
note.setAttributes(attributes);
}
LOG.debug(content);
return noteStore.createNote(note);
}
示例2: create
import com.evernote.edam.type.Note; //导入方法依赖的package包/类
private void create(final ENNote args) throws EDAMUserException, EDAMSystemException, EDAMNotFoundException, TException, ParserConfigurationException, SAXException, IOException {
Note note = new Note();
note.setTitle(StringUtils.abbreviate(args.getName(), EDAMLimits.EDAM_NOTE_TITLE_LEN_MAX));
if (StringUtils.isNotBlank(args.getNotebook().getGuid())) {
note.setNotebookGuid(args.getNotebook().getGuid());
}
ENML enml = new ENML();
enml.setTabWidth(args.getTabWidth());
enml.addComment(args.getComments());
enml.addContent(args.getContent());
note.setContent(enml.get());
for (String tagName : args.getTags()) {
tagName = tagName.trim();
if (StringUtils.isNotBlank(tagName)) {
note.addToTagNames(tagName);
}
}
getNoteStoreClient(args).createNote(note);
}
示例3: toNote
import com.evernote.edam.type.Note; //导入方法依赖的package包/类
public Note toNote() {
Note note = new Note();
note.setTitle("PureNote " + Util.timeStamp(this));
note.setContent(convertContentToEvernote());
if (!"".equals(bookGuid)) {
note.setNotebookGuid(bookGuid);
}
if (!"".equals(guid)) {
note.setGuid(guid);
}
return note;
}
示例4: update
import com.evernote.edam.type.Note; //导入方法依赖的package包/类
private void update(final ENNote args) throws EDAMUserException, EDAMSystemException, EDAMNotFoundException, TException, DOMException, ParserConfigurationException, SAXException, IOException {
NoteStoreClient client = getNoteStoreClient(args);
Note note = client.getNote(args.getGuid(), true, false, false, false);
if (!note.isActive()) {
EDAMNotFoundException e = new EDAMNotFoundException();
e.setIdentifier(EDAMDataModel.Note_noteGuid.toString());
e.setKey(args.getGuid());
throw e;
}
note.unsetResources();
// update content
ENML enml = new ENML(note.getContent());
enml.setTabWidth(args.getTabWidth());
enml.addComment(args.getComments());
enml.addContent(args.getContent());
note.setContent(enml.get());
// update tags
for (String tagName : args.getTags()) {
tagName = tagName.trim();
if (StringUtils.isNotBlank(tagName)) {
note.addToTagNames(tagName);
}
}
note.setUpdated(System.currentTimeMillis());
client.updateNote(note);
}
示例5: create
import com.evernote.edam.type.Note; //导入方法依赖的package包/类
private void create(final ENNote args) throws EDAMUserException, EDAMSystemException, EDAMNotFoundException, TException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException {
Note note = new Note();
note.setTitle(StringUtils.abbreviate(args.getName(), EDAMLimits.EDAM_NOTE_TITLE_LEN_MAX));
if (StringUtils.isNotBlank(args.getNotebook().getGuid())) {
note.setNotebookGuid(args.getNotebook().getGuid());
}
ENML enml = new ENML();
enml.setTabWidth(args.getTabWidth());
enml.addComment(args.getComments());
for (File f : args.getAttachments()) {
// create resource
String mimeType = FileUtil.mimeType(f); // E.g "image/png"
Resource resource = EvernoteUtil.createResource(f, mimeType);
note.addToResources(resource);
// create content
String hashHex = FileUtil.bytesToHex(resource.getData().getBodyHash());
enml.addResource(hashHex, mimeType);
}
note.setContent(enml.get());
// create tags
for (String tagName : args.getTags()) {
tagName = tagName.trim();
if (StringUtils.isNotBlank(tagName)) {
note.addToTagNames(tagName);
}
}
getNoteStoreClient(args).createNote(note);
}
示例6: update
import com.evernote.edam.type.Note; //导入方法依赖的package包/类
private void update(final ENNote args) throws EDAMUserException, EDAMSystemException, EDAMNotFoundException, TException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException {
NoteStoreClient client = getNoteStoreClient(args);
Note note = client.getNote(args.getGuid(), true, false, false, false);
if (!note.isActive()) {
EDAMNotFoundException e = new EDAMNotFoundException();
e.setIdentifier(EDAMDataModel.Note_noteGuid.toString());
e.setKey(args.getGuid());
throw e;
}
ENML enml = new ENML(note.getContent());
enml.setTabWidth(args.getTabWidth());
// update content
enml.addComment(args.getComments());
// update resource
Iterator<File> iter = args.getAttachments().iterator();
while (iter.hasNext()) {
File file = iter.next();
String mimeType = FileUtil.mimeType(file); // E.g "image/png"
Resource resource = EvernoteUtil.createResource(file, mimeType);
note.addToResources(resource);
String hashHex = FileUtil.bytesToHex(resource.getData().getBodyHash());
enml.addResource(hashHex, mimeType);
}
note.setContent(enml.get());
// update tags
for (String tagName : args.getTags()) {
tagName = tagName.trim();
if (StringUtils.isNotBlank(tagName)) {
note.addToTagNames(tagName);
}
}
note.setUpdated(System.currentTimeMillis());
client.updateNote(note);
}
示例7: createNote
import com.evernote.edam.type.Note; //导入方法依赖的package包/类
/**
* Create a new note containing a little text and the Evernote icon.
*/
private void createNote() throws Exception {
// To create a new note, simply create a new Note object and fill in
// attributes such as the note's title.
Note note = new Note();
note.setTitle("Test note from EDAMDemo.java");
String fileName = "enlogo.png";
String mimeType = "image/png";
// To include an attachment such as an image in a note, first create a
// Resource
// for the attachment. At a minimum, the Resource contains the binary
// attachment
// data, an MD5 hash of the binary data, and the attachment MIME type.
// It can also
// include attributes such as filename and location.
Resource resource = new Resource();
resource.setData(readFileAsData(fileName));
resource.setMime(mimeType);
ResourceAttributes attributes = new ResourceAttributes();
attributes.setFileName(fileName);
resource.setAttributes(attributes);
// Now, add the new Resource to the note's list of resources
note.addToResources(resource);
// To display the Resource as part of the note's content, include an
// <en-media>
// tag in the note's ENML content. The en-media tag identifies the
// corresponding
// Resource using the MD5 hash.
String hashHex = bytesToHex(resource.getData().getBodyHash());
// The content of an Evernote note is represented using Evernote Markup
// Language
// (ENML). The full ENML specification can be found in the Evernote API
// Overview
// at http://dev.evernote.com/documentation/cloud/chapters/ENML.php
String content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">"
+ "<en-note>"
+ "<span style=\"color:green;\">Here's the Evernote logo:</span><br/>"
+ "<en-media type=\"image/png\" hash=\"" + hashHex + "\"/>"
+ "</en-note>";
note.setContent(content);
// Finally, send the new note to Evernote using the createNote method
// The new Note object that is returned will contain server-generated
// attributes such as the new note's unique GUID.
Note createdNote = noteStore.createNote(note);
newNoteGuid = createdNote.getGuid();
System.out.println("Successfully created a new note with GUID: "
+ newNoteGuid);
System.out.println();
}
示例8: toNote
import com.evernote.edam.type.Note; //导入方法依赖的package包/类
public Note toNote() {
Note note = new Note();
note.setTitle(getTitle());
note.setContent(convertContentToEvernote());
return note;
}