java unset_Java Note.unsetResources方法代码示例

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();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值