Skip to content

Commit

Permalink
removed semicolons
Browse files Browse the repository at this point in the history
  • Loading branch information
scinfu committed Dec 21, 2016
1 parent fdb1a8d commit 8a4b3c5
Show file tree
Hide file tree
Showing 65 changed files with 6,014 additions and 6,014 deletions.
60 changes: 30 additions & 30 deletions Sources/Attribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,40 @@ open class Attribute {
"formnovalidate", "hidden", "inert", "ismap", "itemscope", "multiple", "muted", "nohref", "noresize",
"noshade", "novalidate", "nowrap", "open", "readonly", "required", "reversed", "seamless", "selected",
"sortable", "truespeed", "typemustmatch"
];
]

var key: String;
var value: String;
var key: String
var value: String

public init(key: String,value :String) throws {
try Validate.notEmpty(string: key);
self.key = key.trim();
self.value = value;
try Validate.notEmpty(string: key)
self.key = key.trim()
self.value = value
}

/**
Get the attribute key.
@return the attribute key
*/
open func getKey() -> String{
return key;
return key
}

/**
Set the attribute key; case is preserved.
@param key the new key; must not be null
*/
open func setKey(key: String) throws {
try Validate.notEmpty(string: key);
self.key = key.trim();
try Validate.notEmpty(string: key)
self.key = key.trim()
}

/**
Get the attribute value.
@return the attribute value
*/
open func getValue() -> String {
return value;
return value
}

/**
Expand All @@ -59,27 +59,27 @@ open class Attribute {
*/
@discardableResult
open func setValue(value: String) -> String {
let old = self.value;
self.value = value;
return old;
let old = self.value
self.value = value
return old
}

/**
Get the HTML representation of this attribute; e.g. {@code href="index.html"}.
@return HTML
*/
public func html()-> String {
let accum = StringBuilder();
html(accum: accum, out: (Document("")).outputSettings());
return accum.toString();
let accum = StringBuilder()
html(accum: accum, out: (Document("")).outputSettings())
return accum.toString()
}

public func html(accum: StringBuilder, out: OutputSettings ) {
accum.append(key);
accum.append(key)
if (!shouldCollapseAttribute(out: out)) {
accum.append("=\"");
Entities.escape(accum, value, out, true, false, false);
accum.append("\"");
accum.append("=\"")
Entities.escape(accum, value, out, true, false, false)
accum.append("\"")
}
}

Expand All @@ -88,7 +88,7 @@ open class Attribute {
@return string
*/
open func toString()-> String {
return html();
return html()
}

/**
Expand All @@ -98,12 +98,12 @@ open class Attribute {
* @return attribute
*/
open static func createFromEncoded(unencodedKey: String, encodedValue: String) throws ->Attribute {
let value = try Entities.unescape(string: encodedValue, strict: true);
return try Attribute(key: unencodedKey, value: value);
let value = try Entities.unescape(string: encodedValue, strict: true)
return try Attribute(key: unencodedKey, value: value)
}

public func isDataAttribute() -> Bool {
return key.startsWith(Attributes.dataPrefix) && key.characters.count > Attributes.dataPrefix.characters.count;
return key.startsWith(Attributes.dataPrefix) && key.characters.count > Attributes.dataPrefix.characters.count
}

/**
Expand All @@ -115,7 +115,7 @@ open class Attribute {
public final func shouldCollapseAttribute(out: OutputSettings) -> Bool {
return ("" == value || value.equalsIgnoreCase(string: key))
&& out.syntax() == OutputSettings.Syntax.html
&& isBooleanAttribute();
&& isBooleanAttribute()
}

public func isBooleanAttribute() -> Bool
Expand All @@ -125,18 +125,18 @@ open class Attribute {


public func hashCode() -> Int {
var result = key.hashValue;
result = 31 * result + value.hashValue;
return result;
var result = key.hashValue
result = 31 * result + value.hashValue
return result
}


public func clone() -> Attribute
{
do {
return try Attribute(key: key,value: value);
return try Attribute(key: key,value: value)
} catch Exception.Error( _ , let msg){
print(msg);
print(msg)
}catch{

}
Expand Down
66 changes: 33 additions & 33 deletions Sources/Attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Foundation
*/
open class Attributes : NSCopying {

open static var dataPrefix : String = "data-";
open static var dataPrefix : String = "data-"

fileprivate var attributes : OrderedDictionary<String, Attribute> = OrderedDictionary<String, Attribute>()
// linked hash map to preserve insertion order.
Expand All @@ -38,7 +38,7 @@ open class Attributes : NSCopying {
@see #hasKey(String)
*/
open func get(key : String)-> String {
let attr : Attribute? = attributes.get(key:key);
let attr : Attribute? = attributes.get(key:key)
return attr != nil ? attr!.getValue() : ""
}

Expand All @@ -48,15 +48,15 @@ open class Attributes : NSCopying {
* @return the first matching attribute value if set; or empty string if not set.
*/
open func getIgnoreCase(key : String )throws -> String {
try Validate.notEmpty(string: key);
try Validate.notEmpty(string: key)

for attrKey in (attributes.keySet())
{
if attrKey.equalsIgnoreCase(string: key){
return attributes.get(key: attrKey)!.getValue();
return attributes.get(key: attrKey)!.getValue()
}
}
return "";
return ""
}

/**
Expand All @@ -65,8 +65,8 @@ open class Attributes : NSCopying {
@param value attribute value
*/
open func put(_ key : String , _ value : String) throws {
let attr = try Attribute(key: key, value: value);
put(attribute: attr);
let attr = try Attribute(key: key, value: value)
put(attribute: attr)
}

/**
Expand All @@ -76,9 +76,9 @@ open class Attributes : NSCopying {
*/
open func put(_ key : String , _ value : Bool) throws {
if (value){
try put(attribute: BooleanAttribute(key: key));
try put(attribute: BooleanAttribute(key: key))
}else{
try remove(key: key);
try remove(key: key)
}
}

Expand All @@ -87,27 +87,27 @@ open class Attributes : NSCopying {
@param attribute attribute
*/
open func put(attribute : Attribute) {
attributes.put(value: attribute, forKey:attribute.getKey());
attributes.put(value: attribute, forKey:attribute.getKey())
}

/**
Remove an attribute by key. <b>Case sensitive.</b>
@param key attribute key to remove
*/
open func remove(key: String)throws {
try Validate.notEmpty(string: key);
attributes.remove(key: key);
try Validate.notEmpty(string: key)
attributes.remove(key: key)
}

/**
Remove an attribute by key. <b>Case insensitive.</b>
@param key attribute key to remove
*/
open func removeIgnoreCase(key : String ) throws {
try Validate.notEmpty(string: key);
try Validate.notEmpty(string: key)
for attrKey in attributes.keySet(){
if (attrKey.equalsIgnoreCase(string: key)){
attributes.remove(key: attrKey);
attributes.remove(key: attrKey)
}
}
}
Expand All @@ -118,7 +118,7 @@ open class Attributes : NSCopying {
@return true if key exists, false otherwise
*/
open func hasKey(key : String) -> Bool {
return attributes.containsKey(key: key);
return attributes.containsKey(key: key)
}

/**
Expand All @@ -129,18 +129,18 @@ open class Attributes : NSCopying {
open func hasKeyIgnoreCase(key: String) -> Bool {
for attrKey in attributes.keySet() {
if (attrKey.equalsIgnoreCase(string: key)){
return true;
return true
}
}
return false;
return false
}

/**
Get the number of attributes in this set.
@return size
*/
open func size() -> Int {
return attributes.count;//TODO: check retyrn right size
return attributes.count//TODO: check retyrn right size
}

/**
Expand All @@ -153,9 +153,9 @@ open class Attributes : NSCopying {
}

if (incoming.size() == 0){
return;
return
}
attributes.putAll(all: incoming.attributes);
attributes.putAll(all: incoming.attributes)
}

open func iterator() -> IndexingIterator<Array<Attribute>> {
Expand All @@ -175,9 +175,9 @@ open class Attributes : NSCopying {
open func asList() -> Array<Attribute> {
var list : Array<Attribute> = Array(/*attributes.size()*/)
for entry in attributes.orderedValues {
list.append(entry);
list.append(entry)
}
return list;
return list
}

/**
Expand All @@ -204,20 +204,20 @@ open class Attributes : NSCopying {
@throws SerializationException if the HTML representation of the attributes cannot be constructed.
*/
open func html()throws -> String {
let accum = StringBuilder();
try html(accum: accum, out: Document("").outputSettings()); // output settings a bit funky, but this html() seldom used
return accum.toString();
let accum = StringBuilder()
try html(accum: accum, out: Document("").outputSettings()) // output settings a bit funky, but this html() seldom used
return accum.toString()
}

public func html(accum: StringBuilder,out: OutputSettings ) throws {
for attribute in attributes.orderedValues {
accum.append(" ");
attribute.html(accum: accum, out: out);
accum.append(" ")
attribute.html(accum: accum, out: out)
}
}

open func toString()throws -> String {
return try html();
return try html()
}

/**
Expand All @@ -227,7 +227,7 @@ open class Attributes : NSCopying {
*/
open func equals(o: AnyObject?) -> Bool {
if(o == nil){return false}
if (self === o.self) {return true;}
if (self === o.self) {return true}
guard let that : Attributes = o as? Attributes else {return false}
return (attributes == that.attributes)
}
Expand All @@ -242,17 +242,17 @@ open class Attributes : NSCopying {

public func copy(with zone: NSZone? = nil) -> Any
{
let clone = Attributes();
let clone = Attributes()
clone.attributes = attributes.clone()
return clone;
return clone
}

open func clone() -> Attributes {
return self.copy() as! Attributes;
return self.copy() as! Attributes
}

fileprivate static func dataKey(key: String) -> String {
return dataPrefix + key;
return dataPrefix + key
}

}
Expand Down
2 changes: 1 addition & 1 deletion Sources/BooleanAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ open class BooleanAttribute : Attribute {


override public func isBooleanAttribute() -> Bool {
return true;
return true
}
}
6 changes: 3 additions & 3 deletions Sources/CharacterExt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extension Character {
public static let BackslashF : Character = Character(UnicodeScalar(12))

//http://www.unicode.org/glossary/#supplementary_code_point
public static let MIN_SUPPLEMENTARY_CODE_POINT : UInt32 = 0x010000;
public static let MIN_SUPPLEMENTARY_CODE_POINT : UInt32 = 0x010000

/// The first `UnicodeScalar` of `self`.
var unicodeScalar: UnicodeScalar {
Expand Down Expand Up @@ -176,7 +176,7 @@ extension Character {
}

static func charCount(codePoint: UInt32) -> Int {
return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT ? 2 : 1;
return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT ? 2 : 1
}

static func isLetter(_ char: Character)->Bool{
Expand All @@ -193,7 +193,7 @@ extension Character {
func isLetterOrDigit()->Bool
{
if(self.isLetter()) {return true}
return self.isDigit;
return self.isDigit
}
}

Expand Down
Loading

0 comments on commit 8a4b3c5

Please sign in to comment.