How to remove hyperlink tag using java
Hello all !!!
I have developed a text editor and also included the function to add a hyperlink. But i dont know how to remove the hyperlink <a href> tag from the generated html using java.Please help me out with any function that can implement remove hyperlink.
Eagerly waiting for the reply.
[319 byte] By [
navsa] at [2007-11-27 7:57:45]

if(htmlTag.toString().equals(HTML.Tag.A.toString()))
{
SimpleAttributeSet sasText = null;
for(int i = caretOffset; i < caretOffset + internalTextLength; i++)
{
parentTextPane.select(i, i + 1);
sasText = new SimpleAttributeSet(parentTextPane.getCharacterAttributes());
Enumeration attribEntries1 = sasText.getAttributeNames();
while(attribEntries1.hasMoreElements() && currentAnchor.equals("http://"))
{
Object entryKey = attribEntries1.nextElement();
Object entryValue = sasText.getAttribute(entryKey);
if(entryKey.toString().equals(HTML.Tag.A.toString()))
{
if(entryValue instanceof SimpleAttributeSet)
{
Enumeration subAttributes = ((SimpleAttributeSet)entryValue).getAttributeNames();
while(subAttributes.hasMoreElements() && currentAnchor.equals("http://"))
{
Object subKey = subAttributes.nextElement();
if(subKey.toString().toLowerCase().equals("href"))
{
anchor = ((SimpleAttributeSet)entryValue).getAttribute(subKey).toString();
Character firstCharacter = anchor.charAt(1);
if(firstCharacter=='j')
{
int size=anchor.length();
int index1 = anchor.indexOf("'")+1;
String value1=anchor.substring(index1, size);
int secondIndex = value1.indexOf("'");
currentAnchor = value1.substring(0, secondIndex);
String str1 = value1.substring(secondIndex+1);
String str2 = str1.substring(69);
String status = str1.substring(14,15);
if(status.equalsIgnoreCase("1"))
{
toolStatus=true;
}
System.out.println("print toolbar Status "+status);
width=str2.substring(0, str2.indexOf(","));
height =str2.substring(str2.indexOf("=")+1, str2.indexOf(")")-1);
newWindow=true;
}
else{
currentAnchor=anchor;
}
break;
}
}
}
}
}
if(!currentAnchor.equals("http://")) { break; }
}
}
parentTextPane.select(caretOffset, caretOffset + internalTextLength);
SimpleAttributeSet sasTag = new SimpleAttributeSet();
SimpleAttributeSet sasAttr = new SimpleAttributeSet();
if(htmlTag.toString().equals(HTML.Tag.A.toString()))
{
if(!htmlAttribs.containsKey("href"))
{
UserInputAnchorDialog uidInput = new UserInputAnchorDialog(parentEkit, Translatrix.getTranslationString("AnchorDialogTitle"), true, currentAnchor,height,width,newWindow,toolStatus);
String newAnchor = uidInput.getInputText();
String value = uidInput.getTarget();
uidInput.dispose();
if(newAnchor != null)
{
htmlAttribs2.put("href",newAnchor);
parentEkit.jmiRemoveAnchor.setEnabled(true);
}
else
{
parentEkit.repaint();
parentEkit.jmiRemoveAnchor.setEnabled(false);
return;
}
}
}
The UserInputAnchorDialogue is my class for the UI of setting a hyperl
navsa at 2007-7-12 19:39:39 >
