FeedAttribute line2Attribute = new FeedAttribute();
line2Attribute.setType(FeedAttributeType.STRING);
line2Attribute.setName("Line 2 Description");
// Create the feed.
Feed siteLinksFeed = new Feed();
siteLinksFeed.setName("Feed For Site Links");
siteLinksFeed.setAttributes(
new FeedAttribute[] {textAttribute, urlAttribute, line1Attribute, line2Attribute});
siteLinksFeed.setOrigin(FeedOrigin.USER);
// Create operation.
FeedOperation operation = new FeedOperation();
operation.setOperand(siteLinksFeed);
operation.setOperator(Operator.ADD);
// Add the feed.
FeedReturnValue result = feedService.mutate(new FeedOperation[] {operation});
Feed savedFeed = result.getValue()[0];
siteLinksData.siteLinksFeedId = savedFeed.getId();
FeedAttribute[] savedAttributes = savedFeed.getAttributes();
siteLinksData.linkTextFeedAttributeId = savedAttributes[0].getId();
siteLinksData.linkUrlFeedAttributeId = savedAttributes[1].getId();
siteLinksData.line1FeedAttributeId = savedAttributes[2].getId();
siteLinksData.line2FeedAttributeId = savedAttributes[3].getId();
System.out.printf("Feed with name '%s' and ID %d with linkTextAttributeId %d"
+ " and linkUrlAttributeId %d and line1AttributeId %d"
+ " and line2AttributeId %d was created.\n",
savedFeed.getName(),
savedFeed.getId(),
savedAttributes[0].getId(),
savedAttributes[1].getId(),
savedAttributes[2].getId(),
savedAttributes[3].getId());
}