import com.evernote.edam.type.Note; //导入方法依赖的package包/类
/**
* Update the tags assigned to a note. This method demonstrates how only
* modified fields need to be sent in calls to updateNote.
*/
private void updateNoteTag() throws Exception {
// When updating a note, it is only necessary to send Evernote the
// fields that have changed. For example, if the Note that you
// send via updateNote does not have the resources field set, the
// Evernote server will not change the note's existing resources.
// If you wanted to remove all resources from a note, you would
// set the resources field to a new List that is empty.
// If you are only changing attributes such as the note's title or tags,
// you can save time and bandwidth by omitting the note content and
// resources.
// In this sample code, we fetch the note that we created earlier,
// including
// the full note content and all resources. A real application might
// do something with the note, then update a note attribute such as a
// tag.
Note note = noteStore.getNote(newNoteGuid, true, true, false, false);
// Do something with the note contents or resources...
// Now, update the note. Because we're not changing them, we unset
// the content and resources. All we want to change is the tags.
note.unsetContent();
note.unsetResources();
// We want to apply the tag "TestTag"
note.addToTagNames("TestTag");
// Now update the note. Because we haven't set the content or resources,
// they won't be changed.
noteStore.updateNote(note);
System.out.println("Successfully added tag to existing note");
// To prove that we didn't destroy the note, let's fetch it again and
// verify that it still has 1 resource.
note = noteStore.getNote(newNoteGuid, false, false, false, false);
System.out.println("After update, note has " + note.getResourcesSize()
+ " resource(s)");
System.out.println("After update, note tags are: ");
for (String tagGuid : note.getTagGuids()) {
Tag tag = noteStore.getTag(tagGuid);
System.out.println("* " + tag.getName());
}
System.out.println();
}