com.hcl.domino.richtext.records.CDLink2 Maven / Gradle / Ivy
/*
* ==========================================================================
* Copyright (C) 2019-2022 HCL America, Inc. ( http://www.hcl.com/ )
* All rights reserved.
* ==========================================================================
* Licensed under the Apache License, Version 2.0 (the "License"). You may
* not use this file except in compliance with the License. You may obtain a
* copy of the License at .
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
* ==========================================================================
*/
package com.hcl.domino.richtext.records;
import java.nio.ByteBuffer;
import com.hcl.domino.data.NativeItemCoder;
import com.hcl.domino.richtext.annotation.StructureDefinition;
import com.hcl.domino.richtext.annotation.StructureGetter;
import com.hcl.domino.richtext.annotation.StructureMember;
import com.hcl.domino.richtext.annotation.StructureSetter;
import com.hcl.domino.richtext.structures.WSIG;
/**
* @author Karsten Lehmann
* @since 1.0.38
*/
@StructureDefinition(
name = "CDLINK2",
members = {
@StructureMember(name = "Header", type = WSIG.class),
@StructureMember(name = "LinkID", type = short.class, unsigned = true)
/* Now comes the variable part: */
/* Null-terminated display comment */
/* Null-terminated server "hint" */
/* Null-terminated anchor text (optional) */
}
)
public interface CDLink2 extends RichTextRecord {
@Override
@StructureGetter("Header")
WSIG getHeader();
@StructureGetter("LinkID")
int getLinkID();
@StructureSetter("LinkID")
CDLink2 setLinkID(int id);
default CDLink2 setTexts(String comment, String hint, String anchor) {
final byte[] lmbcsComment = (comment==null || comment.length()==0 ? "" : comment).getBytes(NativeItemCoder.get().getLmbcsCharset()); //$NON-NLS-1$
final byte[] lmbcsHint = (hint==null || hint.length()==0 ? "" : hint).getBytes(NativeItemCoder.get().getLmbcsCharset()); //$NON-NLS-1$
//anchor text is optional
final byte[] lmbcsAnchor = anchor==null || anchor.length()==0 ? null : anchor.getBytes(NativeItemCoder.get().getLmbcsCharset());
int totalLen = lmbcsComment.length + 1 + lmbcsHint.length + 1;
if (lmbcsAnchor!=null) {
totalLen += lmbcsAnchor.length + 1;
}
this.resizeVariableData(totalLen);
final ByteBuffer buf = this.getVariableData();
buf.put(lmbcsComment);
buf.put((byte) 0);
buf.put(lmbcsHint);
buf.put((byte) 0);
if (lmbcsAnchor!=null) {
buf.put(lmbcsAnchor);
buf.put((byte) 0);
}
return this;
}
default String[] getTexts() {
final ByteBuffer buf = this.getVariableData();
final int len = buf.remaining();
final byte[] lmbcs = new byte[len];
buf.get(lmbcs);
int idxCommentEnd=-1;
int idxHintEnd=-1;
int idxAnchorEnd=-1;
int i;
for (i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy