   constructor: (@value) ->
 
 class Picklist
-  constructor: (@value) ->
+  constructor: (tag) ->
+    @sorted = tag.find('./sorted').text is 'true'
+    plvs = @picklistValues = []
+    tag.findall('./picklistValues').forEach (plv) ->
+      plvs.push factory.build plv
 
-module.exports =
-  Field: Field
-  factory: new Factory()
+class PicklistValue
+  set: (field, value, tag) ->
+    switch field
+      when 'fullName'
+        @fullName = value
+      when 'default'
+        @default = value is 'true'
+      else throw 'unknown field on picklist value object'
+
+module.exports = factory

      when 'defaultValue'
        @defaultValue = value
      when 'picklist'
        @picklist = new Picklist value
      when 'visibleLines'
        @visibleLines = parseInt value, 10
      else throw 'unknown field on field object'

    switch tag.tag
      when 'fields'
        Builder = Field
      when 'picklistValues'
        Builder = PicklistValue
      else throw 'unknown tag type'
    thing = new Builder()
    tag.getchildren().forEach (child) ->
      thing.set child.tag, child.text, child
    thing

factory = new Factory()

class Field
  constructor: ->
  set: (field, value, tag) ->
    switch field
    # required
      when 'fullName'
