1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java Tue May 14 10:14:52 2013 -0700 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java Tue May 14 10:14:52 2013 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -41,7 +41,7 @@ 1.11 * 1.12 * @author Bhavesh Patel 1.13 */ 1.14 -public class RawHtml extends Content{ 1.15 +public class RawHtml extends Content { 1.16 1.17 private String rawHtmlContent; 1.18 1.19 @@ -90,10 +90,61 @@ 1.20 /** 1.21 * {@inheritDoc} 1.22 */ 1.23 + @Override 1.24 public String toString() { 1.25 return rawHtmlContent; 1.26 } 1.27 1.28 + private enum State { TEXT, ENTITY, TAG, STRING }; 1.29 + 1.30 + @Override 1.31 + public int charCount() { 1.32 + State state = State.TEXT; 1.33 + int count = 0; 1.34 + for (int i = 0; i < rawHtmlContent.length(); i++) { 1.35 + char c = rawHtmlContent.charAt(i); 1.36 + switch (state) { 1.37 + case TEXT: 1.38 + switch (c) { 1.39 + case '<': 1.40 + state = State.TAG; 1.41 + break; 1.42 + case '&': 1.43 + state = State.ENTITY; 1.44 + count++; 1.45 + break; 1.46 + default: 1.47 + count++; 1.48 + } 1.49 + break; 1.50 + 1.51 + case ENTITY: 1.52 + if (!Character.isLetterOrDigit(c)) 1.53 + state = State.TEXT; 1.54 + break; 1.55 + 1.56 + case TAG: 1.57 + switch (c) { 1.58 + case '"': 1.59 + state = State.STRING; 1.60 + break; 1.61 + case '>': 1.62 + state = State.TEXT; 1.63 + break; 1.64 + } 1.65 + break; 1.66 + 1.67 + case STRING: 1.68 + switch (c) { 1.69 + case '"': 1.70 + state = State.TAG; 1.71 + break; 1.72 + } 1.73 + } 1.74 + } 1.75 + return count; 1.76 + } 1.77 + 1.78 /** 1.79 * {@inheritDoc} 1.80 */