diff -r 74cd21f2c2fe -r 7a9ef837e57f src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java Tue May 14 10:14:52 2013 -0700 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java Tue May 14 10:14:52 2013 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ * * @author Bhavesh Patel */ -public class RawHtml extends Content{ +public class RawHtml extends Content { private String rawHtmlContent; @@ -90,10 +90,61 @@ /** * {@inheritDoc} */ + @Override public String toString() { return rawHtmlContent; } + private enum State { TEXT, ENTITY, TAG, STRING }; + + @Override + public int charCount() { + State state = State.TEXT; + int count = 0; + for (int i = 0; i < rawHtmlContent.length(); i++) { + char c = rawHtmlContent.charAt(i); + switch (state) { + case TEXT: + switch (c) { + case '<': + state = State.TAG; + break; + case '&': + state = State.ENTITY; + count++; + break; + default: + count++; + } + break; + + case ENTITY: + if (!Character.isLetterOrDigit(c)) + state = State.TEXT; + break; + + case TAG: + switch (c) { + case '"': + state = State.STRING; + break; + case '>': + state = State.TEXT; + break; + } + break; + + case STRING: + switch (c) { + case '"': + state = State.TAG; + break; + } + } + } + return count; + } + /** * {@inheritDoc} */