-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathYLSite.m
More file actions
69 lines (58 loc) · 1.92 KB
/
YLSite.m
File metadata and controls
69 lines (58 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// YLSite.m
// MacBlueTelnet
//
// Created by Lan Yung-Luen on 11/20/07.
// Copyright 2007 yllan.org. All rights reserved.
//
#import "YLSite.h"
@implementation YLSite
- (id) init
{
if ([super init]) {
[self setName: @"Site Name"];
[self setAddress: @"(your.site.org)"];
[self setEncoding: YLBig5Encoding];
}
return self;
}
+ (YLSite *) site
{
return [[YLSite new] autorelease];
}
+ (YLSite *) siteWithDictionary: (NSDictionary *)dict
{
YLSite *s = [[[YLSite alloc] init] autorelease];
[s setName: [dict valueForKey: @"name"] ?: @""];
[s setAddress: [dict valueForKey: @"address"] ?: @""];
[s setEncoding: (YLEncoding)[[dict valueForKey: @"encoding"] unsignedShortValue]];
[s setAnsiColorKey: (YLANSIColorKey)[[dict valueForKey: @"ansicolorkey"] unsignedShortValue]];
[s setDetectDoubleByte: [[dict valueForKey: @"detectdoublebyte"] boolValue]];
return s;
}
- (NSDictionary *) dictionaryOfSite
{
return [NSDictionary dictionaryWithObjectsAndKeys: [self name] ?: @"", @"name", [self address], @"address",
[NSNumber numberWithUnsignedShort: [self encoding]], @"encoding",
[NSNumber numberWithUnsignedShort: [self ansiColorKey]], @"ansicolorkey",
[NSNumber numberWithBool: [self detectDoubleByte]], @"detectdoublebyte", nil];
}
@synthesize name = _name;
@synthesize address = _address;
@synthesize encoding = _encoding;
@synthesize ansiColorKey = _ansiColorKey;
@synthesize detectDoubleByte = _detectDoubleByte;
- (NSString *) description {
return [NSString stringWithFormat: @"%@:%@", [self name], [self address]];
}
- (id) copyWithZone: (NSZone *)zone
{
YLSite *s = [[YLSite allocWithZone: zone] init];
[s setName: [self name]];
[s setAddress: [self address]];
[s setEncoding: [self encoding]];
[s setAnsiColorKey: [self ansiColorKey]];
[s setDetectDoubleByte: [self detectDoubleByte]];
return s;
}
@end